Category "r"

Concatenating strings with multiple separators using paste() in R

See the following reproducible example: require(tidyverse) set.seed(1) reprex_df <- data.frame( var1 = sample(1:10), var2 = sample(11:20), var3 = sam

How to grep a string ending in a specific punctuation mark

I'm trying to grep strings that end in a dash in R, but having trouble. I've worked out how to grep strings ending in any punctuation mark, maybe not the best w

File not found error when running Maxent in biomod2

When I run Maxent into biomod2 I got this error: Error in file(file, "rt") : cannot open the connection In addition: Warning messages: 1: running command 'j

"Error in svd(c) : infinite or missing values in 'x'" when using synth() in R

I am using the synth package in R to implement a synthetic control method, where I use the dataprep() function to construct the appropriate matrices to be passe

Equivalent of validation plot in ggplot

I am trying to write the code to plot validationplot {pls}'s equivalent using ggplot. I could make this using base R, but could'nt figure out how to plot thi

Equivalent of validation plot in ggplot

I am trying to write the code to plot validationplot {pls}'s equivalent using ggplot. I could make this using base R, but could'nt figure out how to plot thi

LaTex not findable during rmarkdown render to pdf [duplicate]

I am havng trouble rendering pdfs in rmarkdown. Everything has been working fine until a point yesterday that I started getting this error mes

What are the differences between R's new native pipe `|>` and the magrittr pipe `%>%`?

In R 4.1 a native pipe operator was introduced that is "more streamlined" than previous implementations. I already noticed one difference between the native |&g

r shiny and ggplot2::facet_wrap how can I add categories to facet_wrap without having the original plot resize?

I have a shiny app that lets the user add categories to the facet_wrap. When I start with one category the plot fills the entire box but when I add a second cat

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

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