Re: [R] correct way to subset a vector

2009-07-09 Thread Marc Schwartz
On Jul 9, 2009, at 10:40 AM, Juliet Hannah wrote: Hi, #make example data dat <- data.frame(matrix(rnorm(15),ncol=5)) colnames(dat) <- c("ab","cd","ef","gh","ij") If I want to get a subset of the data for the middle 3 columns, and I know the names of the start column and the end column, I can d

Re: [R] correct way to subset a vector

2009-07-09 Thread Steve Lianoglou
Hi, On Jul 9, 2009, at 11:40 AM, Juliet Hannah wrote: Hi, #make example data dat <- data.frame(matrix(rnorm(15),ncol=5)) colnames(dat) <- c("ab","cd","ef","gh","ij") If I want to get a subset of the data for the middle 3 columns, and I know the names of the start column and the end column, I

[R] correct way to subset a vector

2009-07-09 Thread Juliet Hannah
Hi, #make example data dat <- data.frame(matrix(rnorm(15),ncol=5)) colnames(dat) <- c("ab","cd","ef","gh","ij") If I want to get a subset of the data for the middle 3 columns, and I know the names of the start column and the end column, I can do this: mysub <- subset(dat,select=c(cd:gh)) If I w