Quantcast
Channel: Active questions tagged r - Stack Overflow
Browsing all 205301 articles
Browse latest View live
↧

Find first occurrence of a character in column of a data frame in R

Struggling with string handling in R...I've got a column of strings in an R data frame. Each one contains the "=" character once and only once. I'd like to know the position of the "=" character in...

View Article


hms function kicking out NAs [closed]

Keep getting this warning message:Warning message: In .parse_hms(..., order = "HMS", quiet = quiet) : Some strings failed to parse, or all strings are NAs And the function replaces all data in my...

View Article


How to fill NA rows by conditions from columns in R

Here is an example:df<-data.frame(v1=rep(1:2, 4), v2=rep(c("a", "b"), each=4), v3=paste0(rep(1:2, each=4), rep(c("m", "n", "o", "p"), each=2)), v4=c(1,2, NA, NA, 3,4, NA,NA), v5=c(5,6, NA, NA, 7,8,...

View Article

webscraping with R and rvest

I have a project where I should scrape a series of articles from news sites. I am interested in the headline and text of the news. In most cases, the site maintains a base URL, for...

View Article

Find time difference for timestamps in similar minute span within the same...

I have many questions about time differences, this one however is unique because I wish to find the time difference between each pair of similar timestamps. I have not been able to successfully do...

View Article


Error: The animation object does not specify a save_animation method

Im trying to create a bar chart race with R following the method delow. While all the pngs are created when I try to save them as a gif file thenI get:Error: The animation object does not specify a...

View Article

count number of values in colum that are in a certain interval, by subgroup

I'm doing something wrong in the following code, as the column selection does not seem to be by subgroup. Can't figure it out.library(data.table) time <- c(1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3) mass...

View Article

Spliting string in column by seperator and adding those as new columns in the...

I have a column in dataframe df with value 'name>year>format'. Now I want to split this column by > and add those values to new columns named as name, year, format. How can I do this in R.

View Article


dplyr / tidy way to filter a vector based on a substring?

We can see some good examples of how to filter a data.frame based on a substring; is there a tidy way of doing this for a vector? (that is, without using grepl() or similar)ExampleI tried what would...

View Article


How to subset a large SpatialPolygonsDataFrame

I want to calculate the area of a wildfire. I tried this by substracting the NDVI calculated on a Landsat image before and another image after the fire and see where the NDVI was reduced. However, not...

View Article

Reducing deviance in glm binomial model

I am trying to fit a glm to large dataset of proportions. The samples in dataset is by spatial grids, where I have count data for mature and immature fishes caught, but the sample size is uneven with...

View Article

Liste of figures/Table and personnalisation of page numbering

I have two questions. The first is to customize the page numbering. No numbering for the title page and the appendix; Roman numerals for the table of contents and list of figures/tables pages; classic...

View Article

identify and mark duplicate rows in r

I would like to identify and mark duplicate rows based on 2 columns. I would like to make a unique identifier for each duplicate so I know not just that the row is a duplicate, but which row it is a...

View Article


Parametric Survival Analysis - Stata vs. R

I am trying to set up a survival analysis in R for which I have a data set with economic data and the code for Stata. The goal of the analysis is to see which impact covariates have on the survival of...

View Article

Image may be NSFW.
Clik here to view.

How to prevent R from rounding in frequency function?

I used the freq function of frequency package to get frequency percent on my dataset$MoriskyAdherence, then R gives me percent values with rounding. I need more decimal...

View Article


Extracting all individual layers from a Raster Brick File

I have stacked 28 layers to a brick in R brik class : RasterBrick dimensions : 720, 1440, 1036800, 28 (nrow, ncol, ncell, nlayers) resolution : 0.25, 0.25 (x, y) extent : -180, 180, -90, 90 (xmin,...

View Article

Image may be NSFW.
Clik here to view.

Fitting a local level Poisson (State Space Model)

I am working through "Forecasting with Exponential Smoothing". I am stuck on exercise 16.4 on the part that states:The data set partx contains a history of monthly sales of an automobile part. Apply a...

View Article


Calculate time duration in seconds of single Date column, while group_by ID in R

Is there a way for R to group by ID, identify a 'break' in time, set this to 0, and then calculate time difference?For instance: ID TIME A 12/18/2019 4:45:10 AM A 12/18/2019 4:45:11 AM A 12/18/2019...

View Article

Image may be NSFW.
Clik here to view.

Make boxes contect clearer to interpret

I want to see check the linear relatioship between all the pairs of variables in a dataset. Because i have 39 variables the scatterplot is not very helpful, so i decided to select a random sample of...

View Article

How to separate out tabs into their own script in a shiny app

I am using several libraries to build a dashboard in shiny.In my ui section I define some tabs, something like this:ui <- dashboardPage(dashboardHeader(title = "Ecommerce Dashboard"),...

View Article
Browsing all 205301 articles
Browse latest View live