For example: When I take a sample of 5 from 10 columns, I want to exclude from the sample column 1 from being chosen. How do I do this? -- View this message in context: http://r.789695.n4.nabble.com/Want-to-exclude-a-column-when-using-sample-function-tp2287988p2287988.html Sent from the R help mailing list archive at Nabble.com.
T.D. Rudolph
2010-Jul-13 21:05 UTC
[R] Want to exclude a column when using sample function
It's not really clear what the structure of your data is, nor how exactly you are sampling it (you need to provide an example), but you could try adding this to the end of your sample command (if the result is a data.frame or matrix): [,-1] Tyler -- View this message in context: http://r.789695.n4.nabble.com/Want-to-exclude-a-column-when-using-sample-function-tp2287988p2287993.html Sent from the R help mailing list archive at Nabble.com.
id pID50 apol a_acc a_acid a_aro a_base a_count 1 mol.11 3.63 -0.882267 -0.527967 -0.298197 -1.032380 0 -1.063410 2 mol.14 3.38 -1.007330 -0.527967 -0.298197 -1.032380 0 -1.063410 3 mol.19 3.18 1.153560 1.407910 -0.298197 1.254100 0 1.160080 4 mol.20 3.14 0.183448 -0.527967 -0.298197 0.873019 0 0.290021 5 mol.29 2.77 -0.273901 -0.527967 -0.298197 0.110860 0 -0.193347 6 mol.30 2.74 -0.230593 -0.527967 -0.298197 0.110860 0 0.000000 7 mol.40 2.16 -1.117550 -0.527967 -0.298197 -1.032380 0 -1.256760 8 mol.45 1.90 -0.383560 -0.527967 -0.298197 0.110860 0 -0.290021 9 mol.48 1.73 -0.383560 -0.527967 -0.298197 0.110860 0 -0.290021 What if I want to exclude 2 columns? For example: sample(data, 3, replace=FALSE) ##from my sample, i want to exclude both id and pID50 Thanks much. -- View this message in context: http://r.789695.n4.nabble.com/Want-to-exclude-a-column-when-using-sample-function-tp2287988p2289092.html Sent from the R help mailing list archive at Nabble.com.