Category "r"

How to install PhantomJS in R Studio?

I wrote a program that needs to run, the following is my R code: library(webshot) webshot("tmp.html","Normal_top100.png", delay =10, vwidth = 1920, vheight=108

How to delay evaluation of function passed as argument to purrr::pmap

I'm trying to use the nested dataframe (https://r4ds.had.co.nz/many-models.html) approach to fit multiple latent class growth curves using lcmm::lcmm() and purr

Sum with particular condition

I would like to know some information, it is possible make a group by with this particular condition: Column Sepal.length take the first value; Sum the column t

Is there an R function to pick only certain row value combinations?

I have a data frame that looks something like this: my_data <- data.frame( letter = c("x","x","x","x","x","y","y","y","y","z","z","z","z"), number = c

Using for loop in R to combine column values based on preceeding column conditions

I am working with a big dataset with multiple observations for a certain gene, on varying dates and with varying expression levels. Data used I would like to su

Image processing 1

Answered my question. Thanks a lot.

Automate Headless Firefox in RSelenium with Profile

I would like to automate an instance of Firefox with RSelenium that is both headless and uses a custom profile (in the simple example below, one that does not l

How to create tertile in R

I Have a column in my dataframe called Score for example DF$Score<-(1.2,2,2,3.2,4.4,4.5,2.5,6.7,8.9,4.8) I want to make a new column containing tertiles of

ggplot with overlapping X axis label

I have a ggplot which looks like this. p2=ggplot(data=data1, aes(x=ID, y = value)) + geom_line(group=1,color='steelblue', size=2) + facet_wrap(~variable)+t

Automatic positioning of images and tables in PowerPoint slide officer

Hi so I have I am trying to write my own function that will automatically size and central align the images/tables that I am generating from officer. The top/le

Create dummy variable with survey package

I want to transform a variable into a dummy using the survey package. I have a complex sample design defined by: library(survey) prestratified_design <- s

How to generate covariate-adjusted cox survival/hazard functions?

I'm using the survminer package to try to generate survival and hazard function graphs for a longitudinal student-level dataset that has 5 subgroups of interest

Can I set a default value for field.types when using dbWriteTable?

I'm trying to write a dataframe to SQL Server using the following line dbWriteTable(conn,"r_test_upload",df, field.types = c(longnotes ="varchar(max)")) By d

R: Reordering Multiple File Path in an object in R [duplicate]

I have 100 files, each named "ABC - Day - 1(to 100).csv". When I read them into R, it is ordered like this: Day1, Day10, Day100, etc. (see fig

R ggplot2 Bar Chart with Round Corners on Top of Bar

I would like to create a ggplot2 bar chart with round corners at the top of the bars. Consider the following example data: data <- data.frame(x = letters[1:

Aligning ggmap and geom_sf maps

I am having problems aligning two maps. They appear to have the same crs but still look off a bit. Notice the California-Nevada border and the California coast.

How to run cor.test() on two different dataframes

I would like to run cor.test() on two seperate dataframes but I am unsure how to proceed. I have two example dataframes with identical columns (patients) but di

The raster overlay function in R produces incorrect values for raster bricks

I'm trying to quantile match two RasterBricks. I am finding the percentile of value<=250 in old_data, which we'll call p. Then I'm finding the value at the p

Relative paths in R: how to avoid my computer being set on fire?

A while back I was reading an article about improving project workflow. The advice was not to use setwd or my computer would burn: If the first line of your

Strange ED50 with drc

I am trying to estimate IC50 values with the drc package. Plotting the model works fine. But when I use the ED I get unreasonable results. In my understandi