I've read this question here: Group numeric values by the intervals
However, I would like to output a numeric (rather than a factor), specifically the numeric value of the lower and/or upper bounds (in separate columns)
In essence, this is right, except that the 'df$start' and 'df$end' are given as factors:
df$start <- cut(df$x,
breaks = c(0,25,75,125,175,225,299),
labels = c(0,25,75,125,175,225),
right = TRUE)
df$end <- cut(df$x,
breaks = c(0,25,75,125,175,225,299),
labels = c(25,75,125,175,225,299),
right = TRUE)
The use of 'as.numeric()' returns the level of the factor (i.e. values 1-6) rather than the original numbers.
Thanks!
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