Category "r"

How to save table1 package output table to .doc format? R

Package "table1" allows for some amazing tables to be made. However, i can't figure how to export one to .doc format. Here is an example code: table1( ~ x | Y

Is there a way to extract Nintendo 3DS activity log data and to use it in R

I am using unmodded hard- and software (New Nintendo 2DS XL, newest firmware version). Any ideas or example of how it is done (without installing custom firmwar

PLM: Cannot add dummy variable

I am currently working on estimating a fixed-effect model using plm(). The following table is an example of my data (please note that I used arbitrary numbers h

Unable to get correct CSS tag for webscraping in R using SelectorGadget

I am trying to web scrape data in R from this url but cannot seem to get the correct css tag. For now I just need help retrieving the professor's name. Any help

Creating predicted vs observed confidence interval graph

Hello and thank you for you time and consideration, I'd like to recreate this graph with ggplot. The top blue dots are the predicted values from my fitted model

Install R packages through "Jobs" tab in Rstudio

In Rstudio, I usually install R packages using the console by install.packages('pkg-name') command. However, when some R packages are required in an R script, R

What is the solution to Error during conditional logistic regression in R?

set<-c(1,1,1,2,2,2) gender<-c(1,0,1,0,1,0) smoke<-c(1,1,0,0, 1,0) case_control<-c(1,0,0,1,0,0) data<-data.frame(set, gender, smoke, case_c

if() statement with paste0() or grep() in r

I made reproducible minimal example, but my real data is really huge ac_1 <-c(0.1, 0.3, 0.03, 0.03) ac_2 <-c(0.2, 0.4, 0.1, 0.008) ac_3 <-c(0.8, 0.043

R stops responding when trying to plot

When trying to draw any plot R just stops responding. plot(1:10) The result is not responding. I am using MacBook M1 pro. It was working perfectly. Just sudden

possible to have separate factor levels for each axis in one graph?

I'm trying to plot a Sankey diagram of financial flows between a source country and counterpart country. ggplot(dat_ggforce, aes(x=x, id=id, split = y, value=yv

convert df into a pairwise distance matrix

I'm using code (not my own) that converts a data frame (Mol.Info) of mass spec peaks and associated elemental ratios into a pairwise distance matrix between mas

How should you package non-R library dependencies?

I am writing an R package which requires a binary file that I have wrapped for use with R code (using system2). To work, the binary file requires a .dylib depen

compute SD and VAR for a time variable

How I am trying to compute SD and VAR for a difference in start and end times, its a time-variable basically, I get a NA when I run: hms::as_hms(var(hms::as_hm

Add unique horizontal line for levels in facet_grid

I want to add a unique horizontal line across each row of a set of facet grid boxplots. x<-c("species_X","species_X","species_X", "species_Y","species_Y",

How to add sequence of numbers to each group of a data.frame?

I have a dataframe of US zipcodes and I want to add a sequence of numbers to each unique zipcode while repeating the rest of the rows. Right now, my data looks

Does the caret package for R properly implement repeated CV when passed a multifold object to trainControl's index option?

I'm hoping the answer to this question is a quick "yes" or "no" but I cannot find it explicitly in the caret documentation or elsewhere online. I want to perfor

Changing values in a raster

I have a raster file (created in QGIS, from a vectorial file). I would like to know if it is possible, in R: 1) to change the values of the pixels? (I believ

Find closest datapoint to a date in another dataframe

I have two data frames. One data frame is called Measurements and has 500 rows. The columns are PatientID, Value and M_Date. The other data frame is called Pati

Finding the turning point (inflection point) of COVID-19 infections using inflection package

I am not sure if I have done my inflection point calculation correctly. Based on lab confirmed cumulative case data in the epicenter of the current epidemic, we

What does the %||% operator do in R? Percent Pipe Pipe Percent

I came across this code when reviewing the R plotly library: modify_list <- function(x, y, ...) { modifyList(x %||% list(), y %||% list(), ...) } What d