Loop to export multiple dataframes in r to Excel and Name Each Sheet
I have 2 data frames that I would like to export to Excel, with each dataframe on a different worksheet, and to title each sheet.I have tried the following with write.xlsx .Here is the list of my 2...
View Articleconvert a netcdf time variable to an R date object
I have a netcdf file with a timeseries and the time variable has the following typical metadata: double time(time) ; time:standard_name = "time" ; time:bounds = "time_bnds" ; time:units = "days since...
View ArticleHow to write a function to loop through variables and plot using ggplot
I'm having problems figuring out how to loop through variables in a data frame and plot them using ggplot. An example of my data is below:head(myData,2) x1 x2 yhat x11 x3 yhat1 x12 1 -0.8523122...
View ArticleWhat distribution should I fit to this data [migrated]
I am trying to find a distribution that fits my data (3500+ data points) with satisfying goodness of fit (gof), I use the Kolmogorov-Smirnov test and its p-value as a gof measurement (p-value >...
View ArticleR expanding the extent of a raster causes problems with gdal
I have a set of rasters created from geotiff files with code like the followingfileName <- "data/xxx.yyy.tif" rasterOutput <- brick(fileName) Most of the the resulting rasterbricks have an extent...
View ArticleBind r data.frames that contain column(s) of nested data.frames
After importing multiple .json files using jsonlite I was looking for ways to bind the resulting data.frames which contained one or more columns which themselves were nested data.frames. I came across...
View ArticleMaximize out-of-sample correlation
Say I have one time-series A of interest, and 10 other time-series B at hand. Then, I pick 3 time-series of the B group, average them, and predict an out-of-sample correlation with time-series A. The...
View ArticleHow to plot positions along a chromosome graphic
I would like to generate a plot depicting 14 linear chromosomes for the organism I work on, to scale, with coloured bars at specified locations along each chromosome. Ideally I'd like to use R as this...
View ArticleFastest way to check all elements in one data.table column for each value...
What is the fastest way to check a full column in data.table R if each value appears in a different data.table column? Example problem:Create example big data:dt1 <-...
View ArticleHow do I use a for loop to create a list of data frames, based off two...
I am VERY new to loops. Some of my loops have been successful, others... not so much.I have some observed data (df_obs) that I'd like to test against my model predictions (df_pred). MY CURRENT AIM:...
View ArticleMultiple x-axis didn't show variable name
i'm try to plot multiple x-axis with shiny.the problem is i can't get variable name(Cities and Month) to show under the chart. the plot i can doI want to show variable name to under the chart. my...
View ArticleTidyverse - rsample. nested_cv + group_vfold_cv = error. Nested...
I am running on the following error:library(tidymodels) nested_cv(data = iris, outside = group_vfold_cv( data = iris, group = Species, v = 2), inside = bootstraps(times = 5)) %>% rsample2caret()...
View ArticleR match date in one table if between two date columns in second table over...
Using base R only, I'm trying to iterate and test if table1$"DATE" is >= table2$"START"& <= table2$"STOP" where table1$"EVENT" == table2$"EVENT". I initially thought to get unique categories...
View ArticleUse ifelse and is.null to test for NULL values
I have a data frame: df <- structure(list(gene = structure(1:6, .Label = c("128up", "14-3-3epsilon", "14-3-3zeta", "140up", "18SrRNA-Psi:CR41602", "18SrRNA-Psi:CR45861" ), class = "factor"), fpkm =...
View ArticleIs it possible to populate R dataframe with two interdependent columns
I am try to use R to calculate sales as a function of inventory as a function of sales. See below data snapshot. Is there anyway to calculate this?Group, Day and Sell_Thru are independent variablesInv...
View ArticleOrder a variable and separate by another variable R
I want to order() a variable by the number of characters it has and then separate that variable based on gender, f and m. How can I do that using R?
View ArticleWoking with Date in R [duplicate]
This question already has an answer here:Converting year and month (“yyyy-mm” format) to a date? 7 answersI have raw data with the date given as189901 which I want to be 1899-01-01 , 189902 which I...
View Articlecreate a cumulative count of adjacent repetitions in a column
I want to create a cumulative count of adjacent repetitions in a column. For instance the desired output for repeat_n in the code below should be c(1,2,3,1,2,1,2), but instead I am getting...
View ArticleConvert character month name to date time object
I must be missing something simple. I have a data.frame of various date formats and I'm using lubridate which works great with everything except month names by themselves. I can't get the month names...
View ArticleIssue with setting up time series correctly in R
I have been trying to do some basic analysis on some timeseries data. However, I keep getting this error on anything I am trying to doError in decompose(data_ts, type = c("additive")) : time series has...
View Article