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 Articlehms 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 ArticleHow 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 Articlewebscraping 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 ArticleFind 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 ArticleError: 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 Articlecount 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 ArticleSpliting 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 Articledplyr / 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 ArticleHow 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 ArticleReducing 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 ArticleListe 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 Articleidentify 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 ArticleParametric 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 ArticleHow 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 ArticleExtracting 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 ArticleFitting 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 ArticleCalculate 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 ArticleMake 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 ArticleHow 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