I am doing some R code practice and is wanting to generate some specific sequence.
I want to use the function seq() to generate sequence, which I have tried the following code, but it seems like character is not available in seq()
n <- c(1 : 100)
seq(from = 1, to = n )
I expect the sequence to be 1 1 2 1 2 3 1 2 3 4.... However, this code isn't able to work
In the following way:
sequence(1:100)
sequence
works by creating a vector from 1
until the number passed to sequence()
Since this function is vectorized, you can insert multiple numbers at once with c(1:100)
at get the necessary output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With