Skip to main content
Adopted example to the numbers of the OP
Source Link
Felix S
  • 4.8k
  • 5
  • 31
  • 37

In R, you can do it using the repcommand:

tab <- data.frame(value=c(1, 2, 3, 4, 5), freq=c(32, 1, 4, 2,5 1))
vec <- rep(tab$value, tab$freq)

This gives following result:

> tab
  value freq
1     1    32
2     2    21
3     3    4
4     4    2
5     5    1

> vec
 [1] 1 1 1 2 2 3 3 3 3 34 4 5

For details, see the help file for the repcommand by typing ?rep.

In R, you can do it using the repcommand:

tab <- data.frame(value=c(1,2,3), freq=c(3,2,5))
vec <- rep(tab$value, tab$freq)

This gives following result:

> tab
  value freq
1     1    3
2     2    2
3     3    5
> vec
 [1] 1 1 1 2 2 3 3 3 3 3

For details, see the help file for the repcommand by typing ?rep.

In R, you can do it using the repcommand:

tab <- data.frame(value=c(1, 2, 3, 4, 5), freq=c(2, 1, 4, 2, 1))
vec <- rep(tab$value, tab$freq)

This gives following result:

> tab
  value freq
1     1    2
2     2    1
3     3    4
4     4    2
5     5    1

> vec
 [1] 1 1 2 3 3 3 3 4 4 5

For details, see the help file for the repcommand by typing ?rep.

Source Link
Felix S
  • 4.8k
  • 5
  • 31
  • 37

In R, you can do it using the repcommand:

tab <- data.frame(value=c(1,2,3), freq=c(3,2,5))
vec <- rep(tab$value, tab$freq)

This gives following result:

> tab
  value freq
1     1    3
2     2    2
3     3    5
> vec
 [1] 1 1 1 2 2 3 3 3 3 3

For details, see the help file for the repcommand by typing ?rep.