Jonas Fransson <jf <at> iva.dk> writes:

> I have a dataframe with two columns,
> where NUMBER is the number of occurrences of DEPTH: 
> 
> > a<-data.frame(c(2,3,2,5),c(1,2,3,1))
> > colnames(a)=c("DEPTH","NUMBER")
> 
> I want a column or a vector where all the DEPTHs are listed: 2, 3, 3, 2, 2, 2,
5 (NUMBER=1 in all cases). 
> 
> Is there any simple solution to the problem?

  with(a,rep(DEPTH,NUMBER))

(in case someone else hasn't already answered)

______________________________________________
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.

Reply via email to