To subset a data frame or matrix:
If you are beginning with the R language, and need tips and help feel free to put down a comment below.
> x <- c(1,2,3,4,5,6)
> y <- c(3,5,2,4,1,4)
> z <- c(2,3,4,3,2,1)
> dataF<-data.frame(x,y,z)
> dataF
x y z
1 1 3 2
2 2 5 3
3 3 2 4
4 4 4 3
5 5 1 2
6 6 4 1
> dataF[2,]
x y
2 2 5
> dataF[2:5,]
x y
2 2 5
3 3 2
4 4 4
5 5 1
> dataF$x <- NULL
> dataF
y
1 3
2 5
3 2
4 4
5 1
6 4
>
If you are beginning with the R language, and need tips and help feel free to put down a comment below.
No comments:
Post a Comment