Wednesday, March 18, 2015

R : Subsetting data

To subset a data frame or matrix:


> 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:

Using Tcpdump to dump and read network traffic

Another Quick FYI tip. There are many network analyzer/reader utilities available on both Linux and Windows platform. There is of-course ...