[R] listing all occurrences in a vector

Jonas Fransson jf at iva.dk
Wed Oct 19 11:00:53 CEST 2011


Dear all,

I have a dataframe with two columns, where NUMBER is the number of occurrences of DEPTH: 

  DEPTH NUMBER
1     2      1
2     3      2
3     2      3
4     5      1

> 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?

Thanks,
Jonas


Jonas Fransson
Ph.D.stud.
 
IVA / Det Informationsvidenskabelige Akademi
Royal School of Library and Information Science
Birketinget 6 
DK-2300 Copenhagen S
T +45 32 58 60 66
D +45 32 34 15 10
www.iva.dk/jf 







More information about the R-help mailing list