Sequence problem in R studio

I am new to R programming and I am stuck in a sequence problem. How do I display (1 1 1 1 1 2 2 2 2 3 3 3 4 4 5) and (4 sevens, 3 twos, 1 eight and 5 ones(7777 222 8 11111)) via a sequence in R programming language?

Thanks,
Saurav

Here's one way, although I'm not at all sure it's what you're really looking for.

c(rep(1,5),rep(2,4),rep(3,3),rep(4,2),5)

Hey Startz,

I want to display two sequences via r programming language

  1. 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5
    2.7777 222 8 11111

Thanks,
Saurav Nandi

Here is a way to do the second one; see if you can use it as a guide to how to do the first one.

inverse.rle(list(lengths=c(4,3,1,5),
                  values=c(7,2,8,1)))

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.