Rollapply for time series
I am trying to calculate the rolling 20 period historical volatility. I take the daily returns:ret<-ROC(data1) And then I use rollapply to get the 20 day HV for each...
View ArticleProblems installing the devtools package
I wish to use the devtools package. I've run the following commands:> install.packages("devtools", dependencies = TRUE) .... > library(devtools) Error in library(devtools) : there is no package...
View ArticleExtend last observed values using na.locf for specific country/variable pairs
I need to use na.locf from the zoo package to replace NA values with the last observed value. However, I need to do this only for specific country & variable pairs. These pairs are specified...
View Articleggplot: How to add a group average value as a line to a grouped bar chart in R?
I would like to add the "All_Parties_average" value to my bar chart as a green line with a legend (see the second picture added by a link). Really appreciate the help!Right now my graph looks like...
View ArticleHow to keep the first four strings in a list?
I have a list of 49 rows. Each line in the list contains a series of strings like below:[[1]] [1] "ANGEL""Jan""R""26""PO""Box""40426""Olympia""WA""98504" [[2]] [1]...
View ArticleI'm getting zip::unzip function error while using user-defined function to...
For starters, I am pretty new in R programming (or programming in general) - so it is possible I made some pretty straightforward mistakes. I need this function to generate feedback for subjects of my...
View ArticleR Plotly rangeselector autoselect "1W"
Right now i got a graph in plotly made in R with the following rangeselector: xaxis = list( rangeselector = list( buttons = list( list( count = 7, label = "1W", step = "day", stepmode = "backward"),...
View ArticleHow to limit the number of rows printed in kable
When using rmarkdown to render pdf document, we can use three options for printing data.frame: default, kable and tibble (see here)With the default option, it is possible to limit the number of rows...
View ArticleWhy do I get an unexpected character error when loading .json files in R
I am trying to load a local json file in R. I am using a package called Sofia that includes the json library. I also tried other packages like rjson and the RJSONIO packages but I get the same error...
View ArticleValidation check on final dataframe to flag irregular calls
so I have a code (see below) which takes allelic discrimination files from BioRad software and runs to generate a final genotype variable.All wells should have a final genotype except for A01, A02,...
View ArticleR imputation for strings in selected columns
I am struggling with multiple data-imputation packages in R and need your advice.I have a data-set with 150.000 rows and 270 columns.Every column has some missing data, but i need to make imputation...
View Articlesaving file with ASCII encoding
I'm trying to save an R script in Rstudio with ASCII encoding, but get the following error:"Not all of the characters in filename.R could be encoded using ASCII. To save using a different encoding,...
View ArticlePandas equivalent to dplyr dot
I am sorry for pretty heavy explanation, but hope you will get the idea.I'm R user and I find tidyverse capabilities in data wrangling really powerful. But recently I have started learning Python, and...
View ArticleR: cleaning pdf text
I have pdf text that I need converted into "tidy" format. But I'm unsure about how to read in the pdf text without compromising the information I need. For example: # install pacman package if you...
View ArticleHow to change Jupyter Notebook theme when using R Kernel?
I want to change the Jupyter theme from within the notebook. I am running R Kernel. I found many options/ suggestions such asjt -t <theme_name> and from within the notebook using!jt -t...
View ArticleArrange ggsurv plots with one shared legend
I am trying to plot several Kaplan Meijer curves in a grid with a shared legend in R. Here (common legend in arrange_ggsurvplots) ggsurvplot_facet is advised. However, in my case, every plot is based...
View ArticleR - comparing simple regression models that were run on several DVs
Say you have the following code in R:model1 <- lm(cbind(DV1, DV2, DV3) ~ IV1 + IV2, data) This code should perform separate regressions of IV1 + IV2 on DV1, then of IV1 + IV2 on DV2 and lastly, of...
View ArticleHow can I get Tukeys letters and/or an LSD for a split plot design?
I have a split plot design with the 6 varieties nested into 5 rates along with 4 replications and would like to see the Tukey's test letters or a number for the least significant difference between the...
View ArticlePlot several segments with a partially common legend
Say that I have the following data frame:line_df <- data.frame(x_ini = c(0.55,2.55,1.55,5.55,7.55), x_end = c(1.45,3.45,2.45,6.45,8.45), y = c(-0.5,-0.5,-1.5,-2.5,-2.5), category =...
View ArticleReturn all elements of a string except a substring in R
I'm trying to extract all elements of a string except for a designated substring. I would like to extract everything except the words select and from, and everything in between. I can extract the...
View Article