Subsetting a list of dataframes by time
I have GPS data in multiple .csv files that I have imported with the following code:library(readr) library(tidyverse) # Data import from target folder filelist <- list.files("data", pattern =...
View ArticleHow to reshape this dataframe?
I have the following dataframe where words took the place of default row numbers (1,2,3, etc.): Score commitment -0.9843452 progress -0.9831530 implement -0.9785868 decision -0.9777243 message...
View ArticleRemove duplicates and manipulate dataframe based on conditions from 2 columns
I've a dataframe as under+------+-----+----------+--------+ | from | to | distance | weight | +------+-----+----------+--------+ | 1 | 8 | 1 | 10 | | 2 | 6 | 1 | 9 | | 3 | 4 | 1 | 5 | | 4 | 5 | 3 | 9 |...
View ArticlePick row with highest value and return rowname
For each column I would like to select the rowname that has the highes value across all rows. Please see my input and output example. > df.t[,1:5][1:5,] MMRF_1021 MMRF_1024 MMRF_1029 MMRF_1030...
View ArticleHow to use two conditions on string search using gsub in R?
I have a vector of characters and I want to search for everytime "RR" appears, and replace by "" empty space. But I can´t miss the "ANRR". I was wondering something like:gsub("RR|!ANRR",...
View ArticleR sf st-intersection keep unmatched rows
I'm trying to create a map that shows the coverage of proprietary data (shapefile). Basically, the outcome will show how much of the contiguous USA is covered by the data. I used st_intersection, but...
View ArticleIs there a package to fit ARMAX GARCH? I can't find one that includes...
I read package introduction of fGarch and rugarch but only find ARMA GARCH. AnalyzeTS seems to fit ARMA first, and then GARCH, then ARMAX GARCH. I don't know why the coefficients are not estimated at...
View ArticleAllocating tasks to parallel workers so that expected cost is roughly equal
I have an assignment problem where I'm trying to allocate a number of tasks with a known expected cost (runtime in seconds) to X parallel workers, subject to the constraint that each worker receives...
View ArticleR ggplot2 legend with linetypes
I am relatively new to R and I have some difficulties with ggplot2. I have a data frame consisting of three variables (alpha, beta, gamma) and I want to plot them together. I get the plot but I have...
View ArticleIsolating plots individually for layout editing in R (with ggplot)
I recently received some help from a kind member of this forum to create the series of plots below. Datasets have been dputed at the bottom of this post:p<-ggplot(dat, aes(x = hour, y = Y, fill =...
View ArticleScatterplot with latest available observation
I am finding some issues with creating a scatterplot based on the latest available observation per each variable. I would like to take the latest obs per each variable and each country and then compute...
View ArticleHow do I silence output to stdout in rpy2?
I have an R function that I call from my Python script using rpy2. The R function prints to stdout; is there a parameter in rpy2 that silences stdout when an R script is called?
View Articlevegdist function cannot handle datasets of abundance containing 0
As a marine biologist, we need to figure out whether the fish abundance of 4 different fish species counted three times over a year differs from one artifical reef to another (reef A, B, and C) and...
View ArticleR Bookdown - Customize width of TOC/Sidebar
Although I can change the width and position of different elements in the body of an r bookdown doc by modifying the page wrapper in the .css, is there a way to change the width of the sidebar by...
View ArticleExtract value from a loop function to add in columns
I would like to run the NLSstAsymptotic function for each of my columns (X1:X3 in the example data sheet, my real data sheet has many more columns and rows). From the values the function returns, I...
View ArticleShade area under a curve [duplicate]
I'm trying to shade an area under a curve in R. I can't quite get it right and I'm not sure why. The curve is defined by # Define the Mean and Stdev mean=1152 sd=84 # Create x and y to be plotted # x...
View ArticleHow to take value from i+1th column of 1 df and calculate distance to values...
Suppose I have the following two dataframes (with uneven rows)set.seed(1999) dfA <- data.frame(x = rpois(10,2), y = rpois(10,2), z = rpois(10,2), q = rpois(10,2), t = rpois(10,2)) set.seed(24) dfB...
View ArticleConverting from NCR to Unicode in R
I have some html files (I'm working with them as plain texts) that utilize decimal NCR to encode special characters. Is there a way to convert them conveniently to Unicode using R? NCR codes does not...
View ArticleRecode data values in a dataframe into combined values in R
Im trying to compare marital status and my variables have names of "married", "not married", "engaged", "single", and "nota married". How would I make this data only read as "married" and "not...
View Articlescatterplot of mean, max and min with datetime
I am working for the first time with a table containing dates and time and I am really struggling with making what I thought it was a simple plot. The table looks like this: A B 1 2018-01-01 11:49:00...
View Article