I have 503 datapoints and I want to cut away the last 250 to get the 253.
I tried cut ,but these function only gives me groups back...
How can I do that in R?
In addition to the above answer, you can pass any vector in the square brackets to reduce your vector. The above case you are dropping the last 250 values. You can play around with the values inside the square brackets to get different results
# Generate some values
vals <- rnorm(503)
# Take the last 250
result <- vals[250:503]
# Take 1,3,4,7 values
result <- vals[c(1,3,4,7)]
# Take alternate values
result <- vals[seq(1,503,2)]
etc...
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