Hello everybody How do you subset a data.frame when your boundaries are a combination of explicit and implicit limits? For example, I need to subset from the fourth (explicit) to the last (implicit) column a data.frame named A. In other languages you would do A[ , 4:]. Would anybody show me the R's way? Thank you, Your culprit -- View this message in context: http://www.nabble.com/subsetting-of-a-data.frame-tp23655883p23655883.html Sent from the R help mailing list archive at Nabble.com.
You can for example use ncol(A) to get the number of columns. Sarah On Thu, May 21, 2009 at 12:06 PM, culpritNr1 <ig2ar-saf1 at yahoo.co.uk> wrote:> > Hello everybody > > How do you subset a data.frame when your boundaries are a combination of > explicit and implicit limits? > > For example, I need to subset from the fourth (explicit) to the last > (implicit) column a data.frame named A. > > In other languages you would do A[ , 4:]. Would anybody show me the R's way? > > Thank you, > > Your culprit > >-- Sarah Goslee http://www.functionaldiversity.org
Dear culprit Try this: A[ , 4:ncol(A) ] HTH, Jorge On Thu, May 21, 2009 at 12:06 PM, culpritNr1 <ig2ar-saf1@yahoo.co.uk> wrote:> > Hello everybody > > How do you subset a data.frame when your boundaries are a combination of > explicit and implicit limits? > > For example, I need to subset from the fourth (explicit) to the last > (implicit) column a data.frame named A. > > In other languages you would do A[ , 4:]. Would anybody show me the R's > way? > > Thank you, > > Your culprit > > > -- > View this message in context: > http://www.nabble.com/subsetting-of-a-data.frame-tp23655883p23655883.html > Sent from the R help mailing list archive at Nabble.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. >[[alternative HTML version deleted]]