[R] Frequency table

Jess L tszhenzhenj at hotmail.com
Thu Nov 24 04:25:31 CET 2011


I think you can try the function rep().

# this means rep 1 once, 2 twice and 3 three times
> rep(c(1,2,3), c(1,2,3))
[1] 1 2 2 3 3 3

# this means rep "A", "B", "C", until it reaches length of 10
> rep(c("A","B","C"), length.out = 10)
 [1] "A" "B" "C" "A" "B" "C" "A" "B" "C" "A"

you can try more example by type:

hope this helps~

View this message in context: http://r.789695.n4.nabble.com/Frequency-table-tp4101612p4102614.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list