Category "r"

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

R: slicing over dates in a dataframe using custom time window

I have a dateframe of player rankings over many years (2000-2020), which looks like : Now, I wish to group_by() and summarise() and calculate statistics for di

How to add a line break in Rmarkdown code?

I have an rmarkdown document with this: `r {"### MyHeading"}` I would like to add a line break after this (no text, just an empty line). How can I accomplish

Plotly/Vistime - overlapping labels

I have a simple timeline I've built using Vistime/Plotly: library(vistime) library(plotly) data <- read.csv(text="event,group,start,end,color

Non-linear Optimization solnl function error in R: 'Argument of length zero'

I am trying to implement CVaR portfolio optimisation in R. Basically trying to replicate the Matlab approach used in this paper: https://ethz.ch/content/dam/et

table for multiple variables with multiple labels

I am trying to create a expss like cross table for multiple variables . i have a database which already labelled. df <- data.frame("TB1"=c("OPS", "OPS", "HR

Converting atan2 Excel code to R, to produce flow direction in Cartesian Coordinates

I have earth flow displacements in two directions, converted to point data, which I am trying to combine for an overall offset direction (point to where the flo

Calculate NPV for cashflows at all point in time

I have the following data frame contains cash flows for several items. For example: test <- data.frame(ID = c(rep("A",3), rep("B",4)), time = c("y3

Find optimum in combination of groups out of individuals due to certain criteria

I would like to form random groups out of a number of individuals. For the individuals I have information about their location (two possibilities) and the team

How can I read multiple csv files into R at once and know which file the data is from?

I want to read multiple csv files into R and combine them into one large table. I however need to a column that identifies which file each row came from. Basica

I can't install packages in R

A few days ago I wanted to install a certain package in R that wasn't available in the older version of R. I installed new version of R and R studio and now the