HI, I have a file named "s1"(which has 14 rows and 4 columns) which is in csv format. I import and call it "A" the file using: A <- read.csv(file="s1.csv",head=TRUE,sep=",") then I transpose it and call it "B"(which will have 4 rows and 14 columns) using: B=t(A) when I want to make 5 samples from "B" (choosing 10 columns) using: result=replicate(5,B[,sample(colnames(B),10)],simplify=FALSE) I get the following error: "Error in sample(colnames(B), 10) : invalid 'x' argument" anyone has any idea,why?and how to fix it? Thanks -- View this message in context: http://www.nabble.com/Error-in-sample%28colnames%28B%29%2C-10%29-%3A-invalid-%27x%27-argument-tp20094713p20094713.html Sent from the R help mailing list archive at Nabble.com.
Patrick Burns
2008-Oct-21 20:25 UTC
[R] Error in sample(colnames(B), 10) : invalid 'x' argument
What I would do (and I think a lot of people on this list) is to type: colnames(B) to see why 'sample' might not like it. There are debugging tools in R, this seems like a good opportunity to use them. Patrick Burns patrick at burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") Alex99 wrote:> HI, > > I have a file named "s1"(which has 14 rows and 4 columns) which is in csv > format. I import and call it "A" the file using: > > A <- read.csv(file="s1.csv",head=TRUE,sep=",") > > then I transpose it and call it "B"(which will have 4 rows and 14 columns) > using: > > B=t(A) > > when I want to make 5 samples from "B" (choosing 10 columns) using: > > result=replicate(5,B[,sample(colnames(B),10)],simplify=FALSE) > > I get the following error: > > "Error in sample(colnames(B), 10) : invalid 'x' argument" > > anyone has any idea,why?and how to fix it? > > Thanks >