Category "r"

Replace NA only within specific range of time series object

I have the following data stored as zoo object: A B C 2017-05-31 NA NA 3.1 2017-06-30 2.5 2.4 3.2 2017-07-

How to change TOC depth in R Bookdown (GitBook)?

I use GitBook format through R bookdown. I need to use at least four levels in the table of contents (TOC). The default is three. How can I change the depth of

How to convert months as factors while still maintaining the months in sequence?

I have a original data frame (df) containing data of around 10 years(1994-2003). The head(df) is as shown below: Sl.no Date Year Month Season

If I imported my dataframe in R and can run associate() why is ALL_CORRELATION giving me an error?

All I have is a simple dataframe with 27 columns and 100 rows I continue to get the following error although the simple line of code works with other example of

Create several folders in a directory with a loop to write the names R

I am trying to create several subfolder in a parent folder. I created this code but it does not create my subfolders. I would like to create subfolders in the f

How to merge output of lapply iterated function into 1 dataframe? [duplicate]

I have a function responses to process some data that is subset into different data frames. I also have a list of these data frames partylist.

Parallelize st_union from R's sf package

I have some large shapefiles with multiple millions of polygons that I need to dissolve. Depending upon the shapefile I need to either dissolve by group or jus

Getting plots from R to powerpoint

I use "ggplot2" to create beautiful plots in R. I want to distribute them; I use "ReporteRs" get them into PowerPoint. When I do this the formatting is somehow

R R6 Inheritance with roxygen2 - class "ParentClass" is not exported by 'namespace:ParentPackage'

I am running into an issue with R6 inheritance. I am writing 2 packages (work related so I have to use fake code but I'll try to keep it accurate). In ParentPac

How to implement regressors in a Hierarchical Series in R, with the Fable package?

I am new to exploring the fable package, and I was wanting to implement Regressors in a Hierarchical Time Series model. How should the Dimensionality of the dat

Is there a way to paste 2 "ftable" object?

I`m using svyby from survey to make some weighted ratios with their standard deviation and coefficient of variation, I use the code below to generate a three wa

Vertical align kable's column name

Suppose the next example: library(knitr) library(kableExtra) df <- data.frame(a = letters[1:10], b = 1:10) names(df) <- c("This is a looooooong title,

How to remove rows with single unique ID in R?

I have the dataset as coded below. For a specific set of treatment pair, year, month, level, I have assigned a unique ID. Ideally, a compelete "set" has two row

Rendering many Rmds from command line using GNU parallel

To knit an Rmd from the command line, you can do the following and it creates an HTML Rscript -e "rmarkdown::knit('test.Rmd')" I want to do this for many Rmds

R Markdown, output test results in loop

I'm looking for a nicely formated markdown output of test results that are produced within a for loop and structured with headings. For example df <- data.f

creating function to obtain result of table

I want to create a function with the summary I am creating with the code below. I tried this but it doesn't work for me. library(expss) df <- data.frame("TB1

Multi-level list to data frame in R

I'd like to convert the below list to a data frame but I'm failing at doing it. The list is taken from Microsoft Azure's API listing all resource types with tec

Why is my risk ratio reported to be 1 with NA-NA confidence interval?

I am trying to calculate the risk ratio for coinfection using the code: *NET_post4['VCandShig']<-NA NET_post4$VCandShig <- ifelse(NET_post4$VC=="Negative

How to pipe purely in base R ('base pipe')?

Is there a way to pipe in base R, without having to define your own function (i.e. something 'out of the box'), and without having to load any external packages

How to cite within a figure caption w/ rmarkdown native citation?

In R Markdown, I want a figure caption with a linked citation in R Markdown native citation style [@ref]. However, when I insert the [@hawking_thermodynamics_19