On 18.04.2010 15:46, Amit wrote:
Hi! All, I am working on a dataset 'rat' with dimension 20500x363. I have calculated pca of samples (columns). Now I am trying to plot first two principle components with specified columns in different color. I have done following so far:dim(rat)[1] 20500 363#specifying columns to be colored in red a1=colnames(rat[,c(1,5,9,12,16,154,227,276,284,298,305,311,318,336,338,drop=F)]) #specifying columns to be colored in blue a2=colnames(rat[,c(2,3,4,6,13,14,drop=F)]) #specifying columns to be colored in green a3=colnames(rat[,c(7,8,10,11,15,29,35,36,50,54,57,59,61,63,70,71,79,99,110,132,147,163,166,215,275,drop=F)]) #specifying columns to be colored in brown d=colnames(rat[,-c(1,5,9,12,16,154,227,276,284,298,305,311,318,336,338,2,3,4,6,13,14,7,8,10,11,15,29,35,36,50,54,57,59,61,63,70,71,79,99,110,132,147,163,166,215,275,drop=F)]) #calculating pca for columns rat_pca=prcomp(t(rat),scale=T) plot(rat_pca$x,pch=20,col=c("red","blue","green","brown")[c(a1,a2,a3,d)])
Well probably a1, ... contain *names* rather than numbers, hence you get a color vector containing only NAs, i.e. are not plotted.
Uwe Ligges
But after executing last command there is nothing plotted in the graph and it also does not give any error. Please help! regards Amit ______________________________________________ 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.
______________________________________________ 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.