Category "r"

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

RStudio: Selecting the column with the latest available data from a dataframe

I am trying to extract data from the World Bank and import it into RStudio for a regression analysis. The data can be found here and as you can see, the online

How can I add a legend for error bars in ggplot?

I have been trying to amend what I thought was a straightforward legend on my GGPlot for a day now and not making much progress (I have searched extensively on

Timezones when working with VEMCO VR2AR acoustic telemetry data

I'm wondering what the typical procedure for working with timezones for acoustic telemetry data is (part of a GLATOS array). If VR2AR receivers were initialized

rselenium clicking on dropdown element to collect data

I am trying to collect some area names from a website and in order to do so I want to click the drop-down box to expand the downwards pointing arrow. i.e. on th

create multiple tab in CSV file through R

I have a query in R, for loading data into .xlsx multiple tabs we use below code write.xlsx(newtrain, file = 'path/file.xlsx', sheetName