Entering edit mode
7.6 years ago
mbk0asis
▴
700
Hi.
I'm trying to read a list of strings and 'grep' them one by one from a data frame and draw and save the plots using R 'for loop' function. However, I got warning message and nor plots.
"Warning message:
In grep(cpg, colnames(dta)) :
argument 'pattern' has length > 1 and only the first element will be used"
Here's the code I used,
for (cpg in cpg.list){
dta1 <- dta[,grep(cpg,colnames(dta))]
jpeg(paste(files[cpg]), '.jpg', width = 700, height = 500)
par(mar=c(3,3,3,3))
stripchart(dta1, method='jitter', vertical=T)
boxplot(dta1, add = T)
dev.off()
}
Can someone explain what I did wrong?
Thank you!
Try to print out the content of the cpg variable, it's probably not what you think it is.
Based on the error message it's a vector (while you expect it to be a simple character string if I'm not mistaken).
please provide output for
and
and contents of