I am trying to create a new vector C by subsetting all the numbers from a vector A which are smaller than 25 and greater than 75. My problem is how and where to position the command subsetting the range I want.
set.seed(135)
A <- sample(1:100,1000, replace=T)
C <- A[seq(1,length(A),)]
I know that I can subset an nth object by putting a number after the last comma like so:
B <- A[seq(4,length(AA),4)
So I tried to put the range I want to be excluded there but I just get a bunch of errors:
Error: unexpected ',' in "C <- A[seq(1,length(A),(x<25,"
> C <- A[seq(1,length(A),x<25,x>75)]
Error in seq.default(1, length(A), x < 25, x > 75) :
object 'x' not found
> C <- A[seq(1,length(A),(A<25,A>75))]
Error: unexpected ',' in "C <- A[seq(1,length(A),(A<25,"
> C <- A[seq(1,length(A),A<25,A>75)]
Warning message:
In seq.default(1, length(A), A < 25, A > 75) :
erstes Element von 'length.out' Argument benutzt
I need the first set of the sequence to look like this:
[1] 4 93 10 85 8 89 16 91 84 85 ...