I have issues getting this R code to run. I want to compute quantiles of SCORE1 below and then categorize score2 by quantiles of score1 (0.2, 0.4, 0.6, 0.8). However, the 2 R codes below do not run properly. Could you help figure out what the issue is?
df <- data.frame(ID = 1:10, Score1 = c(78, 82, 65, 90, 72, 88, 55, 67, 92, 81), Score2 = c(89, 95, 76, 82, 91, 85, 72, 68, 97, 88))
df$quartile <- with(df, factor(findInterval (score1, c(-Inf,quantile(score1, probs=c(.2,.4,.6,.8)),Inf),na.rm=TRUE), labels=c('Q1','q2','Q3','Q4'.'Q5')))
df$quartile <- with(df, cut(score1, breaks=quantile(score1, probs=seq(0,1, by .2),na.rm=TRUE), include.lowest=TRUE))