Hi Chintanu, Do you want the correlation of columns 3:10 of file with the y vector or do you want a correlation matrix of all variables?
## correlation between cols 3:10 and y sapply(file[1:47231, 3:10], FUN = cor, y = rep(LGD, 47231), method = "pearson") ## correlation matrix cor(cbind(file[1:47231, 3:10], rep(LGD, 47231)), method = "pearson") HTH, Josh On Sun, Aug 14, 2011 at 7:02 PM, Chintanu <chint...@gmail.com> wrote: > Hi, > > I am not sure how to fix the following error. > > LGD <- c(11.6, 12.3, 15.8, 33.1, 43.5, 51.3, > 67.3, 84.9) > > cor (x=(file [1:47231,3:10]), y= rep (LGD, 47231), method = "pearson") > > Error in cor(x = (file[1:47231, 3:10]), y = rep(LGD, 47231), method = > "pearson") : > > incompatible dimensions > >> sessionInfo() > > R version 2.13.0 (2011-04-13) > > Platform: i386-pc-mingw32/i386 (32-bit) > > locale: > > [1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 > LC_MONETARY=English_Australia.1252 > LC_NUMERIC=C LC_TIME=English_Australia.1252 > > attached base packages: > > [1] stats graphics grDevices utils datasets methods base > > loaded via a namespace (and not attached): > > [1] tools_2.13.0 > > Thank you. > > Kind regards, > > Chintanu > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, ATS Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.