Category "r"

split the lines of a data frame into a variable number of lines based on a character in R [duplicate]

I have this df: df = data.frame(ID = c(1,2,3), A = c("h;d;c", "j;k", "k")) And i want to retrieve a new df with splited rows ba

How to add_trace to a plotly object created from ggplotly in R

I want to be able to add a new line/trace to a plotly object. This plotly object will be created from a ggplot object using ggplotly. I tried 1. creating the pl

avoid "pandoc document conversion failed with error 61" for `github_document`

I keep failing to knit a github_document because of the error shown below. A solution to avoid this was provided in this question for html_document. But that ar

R phylo object: how to connect node label and node number

A phylo object in R can have internal node labels (phylo_obj$node.label), but many R functions use node numbers instead of the node labels. Even the phylo objec

Webscraping with right html_element in R

This code worked two weeks ago but is not working now. Is it possible that html_elements were changed? How can I get the updated ones - without not changing the

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