Questions tagged [r]

R is a free, open-source programming language & software environment for statistical computing, bioinformatics, visualization & general computing. Please use minimal reproducible example(s) others can run using copy & paste. Show desired output. Use dput() for data & specify all non-base packages with library(). Don't embed pictures for data or code, use indented code blocks instead. For statistics questions, use https://stats.stackexchange.com.

454,213 questions
0votes
0answers
7views

Calculate ratio based on some conditions

I'd like to make a little bit function: # My data set id<-c(1,1,2,2,2,2,2,2,2,2,2,2,2,2) days <- c(0,60,0,47,76,118,160,193,227,262,306,355,396,450) AT <- c(0.1100,0.1500,0.1400,0.4800,0.8300,...
0votes
0answers
6views

How do I add line plots/distributions to a histogram in R?

The following is my code, and I would like to get the dpear and ppear plots to appear on the histogram, just as I have done with the density curve, but I am running into some issues trying to do that. ...
0votes
0answers
10views

Filter for specific combination of two IDs

I have a dataframe my_df which already has some values for an ID/Date combination: set.seed(42) my_df <- data.frame(ID = c('A', 'B', 'C', 'A', 'B'), Date = seq(lubridate::date('...
0votes
1answer
9views

Reset match token only works every two characters

I would like to add a full stop between each letter of a word using the reset match token (\K). I don't want to use a positive lookbehind. gsub("\\pL\\K", ".", "adskhfks",...
0votes
0answers
7views

taking the max value in columns including vectors in a dataframe

I have a dataframe like below: ID Name R1 R2 R3 A1 c("Rob","Rob") 27 29 100 A2 c("Emil&...
-1votes
2answers
18views

Improve benchmark of function in R

I am currently dealing with a benchmarking problem and I am willing to use the vectorization of R for faster calculation however I do not really have a clue how I can improve the speed. Help is much ...
0votes
0answers
16views

R create a plot in ggplot

I want to create a plot in ggplot ggplot(data = data , mapping = aes(x = x, y =y)) + geom_point() my data: x = chr [1:1640] y = chr [1:1640] but unfortunately I get an error: Error in ...
0votes
0answers
9views

Discrepancy between anova model output and graphic when offsetting to different null

I am trying to test if the mean of the values val for each level is significantly greater than 1. I can't seem to resolve the discrepancy between the estimates I see in a plot vs the linear model set....
-2votes
0answers
18views

Reading KEGG annotation online: --> No gene can be mapped.... --> Expected input gene ID: 7360,10720,3418,6120,3099,130589 --> return NULL

entrez <- bitr(rownames(dds_selected), fromType ='ENSEMBL', toType ='ENTREZID', OrgDb = org.Hs.eg.db, drop = TRUE) head(entrez) duplicated(entrez$ENSEMBL) xy <- entrez[!duplicated(entrez$...
0votes
1answer
27views

how to create a new column where the rows are determined by the previous row (calculation)?

I have this table and I want to calculate inflation for every month in every city I tried the lag and lead functions but the CPI was overlapping onto the next city for ex : Malmo's shifted CPI was ...
-1votes
0answers
15views

R - OpenTripPlanner - The max walk/bike/car distance is reduced to 50 km from Infinite

I try to calculate an itinerary by car to find a distance and a time for a trip with OTP 2.0.0 with the R package but OTP does not let me calculate any trip longer than 50km (Euclidien distance). I ...
-2votes
0answers
17views

Integration of scale bars on time series decomposition plots

I recently saw an article where I unfortunately can't track the author to raise the question directly. So he performed a regular time series decompoensation with R where he was able to insert a bar (...
0votes
0answers
22views

Checking class of selectInput in Rshiny

I would like to ask if it is possible to check the class of the selectedinput generated by the datatable. Is it possible to check the class of the selectedinput? (It will be the x axis) I want to plot ...
1vote
2answers
17views

Checking if a date falls within an interval in a dataset in long format

I have two datasets with tests (dates and results - long format) and meds (medication dates) for a number of patients. There are two tests per patients, on two separate dates. (tests <- structure(...
-1votes
0answers
11views

Segmentation fault during matrix inversion in R

I am trying to perform a matrix inversion with R on a High Computation Cluster. My R script is as follows: A = read.csv( "data.csv", header = FALSE ) I = diag(nrow(A)) L = solve( (...

153050per page