Category "r"

R - Created package documented with roxygen2 is there a way to create a PDF of all the functions documentation? [duplicate]

As I explained in the question, I made an R package using devtools and roxygen2. When I type ?function the roxygen2 documentation displays in

Adjusted Survival Curves in R From Cox Model at Specific Covariate Values

I'd like to plot adjusted survival curves from a Cox model at specific covariate values. The survfit function in the survival package and ggsurvplot in survmine

Dplyr Lags on Summarised Grouped Data

Using dplyr, I'm looking to summarise a new column of data as a lagged version of an existing column of grouped data. Reprex: dateidx <- as.Date(c("2019-

Create and fill new columns based on range information from two other columns

I have the following data: df <- data.frame(group = c(1, 1, 1, 2, 2, 2), start = c(2, 2, 2, 7, 7, 7), stop = c(4, 7, 8,

Avoiding a Loop to Extract Vectors From Rows in Dataframe in R

I have data in a text file in which the cases are stacked in a single column. I need to extract selected lines from each case into vectors. I know how to do t

How to fix pandoc (error 1) in rmarkdown for html output?

I'm using pandoc version 2.18 and R version 4.1.3. I'm using rmarkdown to knit a document into an html format, but repeatedly receive the following error: pando

Subset rows of a table if they contain a specific character vector

I know this is a common question and I've read through many other stackoverflow entries but I am still stuck, apologies! I'm a beginner to R (still!). I have an

Reverse order of bar chart colours while keeping legend order and colours

I am working on ggplot2 in R, and have used automatic colouring for the plot. It plots stacked bar charts and then converts them to the pie chart. Here is the c

Issue with running Tidyverse

Hi the error message I get when I use library(tidyverse) is: Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(j <- i[[1L]

How do i replicate these plots using ggplot?

plots This is what I have tried so far. The box plot is kind of close, but the other plot is way off. ggplot(data_anova, aes(x = delay, y = soa, color = age)) +

I have made this function which returns a tibble of 100 * 2. its working absolutely fine but I need to set two constants for the 1st two observations

Here's my code below. ar2 <- function(n , c ,phi1, phi2, sigma){ if( (phi2 > -1) & (phi2 < 1) & (phi1 + phi2 < 1) & (phi2 - phi1 &

R error message output goes off the slide in beamer presentation R markdown

I'm using R markdown to make a beamer presentation. When I try to include an error message output from R on the slide it goes off the page. Here is my code: ---

Is there a way to vectorize seq() and grep() to use on conjunction with dplyr?

Apologies if this is obvious, I don't have much experience with R. I have a function contains_leap_year(date1, date2) that I want to pass in as a condition to d

Prevent .libPaths() in R from resolving symlinks

I have two almost identical systems. I install software in system1 (a remote testing environment) in /export/apps/ and then rsync the files to system2 in its /

Custom interaction Plotly in ggplot - R

I have a massive dataset that makes graph plotting tedious and complex. Assume this simplified dataset: library(data.table) library(plotly) library(ggplot2) lib

R: create diagonal from 1 to 10 in matrix -> returns only last value

I need to modify a matrix filled with random numbers so that the resulting matrix has a diagonal with the numbers 1 to 10 and everywhere else there are supposed

Different output when running lmer and summarise

I am doing some easy linear mixed effects model as below: lmer( as.numeric(o.m_20_r_coded)~ site + (1 | village), o.m_20_r_coded_dat) %>% summary() Random

Create several new variables using a vector of names and a vector for computation within dplyr::mutate

I'd like to create several new columns. They should take their names from one vector and they should be computed by taking one column in the data and dividing i

Facing error with terraform code for importing multiple runbook to azure automation account

I have created the azure automation account using terraform code. I have multiple runbooks PowerShell scripts saved in my local. I am using for.each option to i

Merging three dfs of different row lengths

I need to merge three separate DFs ("factors_sed", "resp", and "npoc_sed") based on the shared column "Samples". Each DF contains a different number of rows (s