frazman
frazman

Reputation: 33223

Row extraction based on an index in R

A newbie in R.

I have a dataframe data which has a lot of rows in it..

data <- read.table("data.txt", header=T)

What I want is to extract only rows 20-50 from this whole dataframe.

So,something like row slicing??

data.subset <- subset(data,....)?

I was trying the approach mentioned in the this site: http://www.r-tutor.com/r-introduction/data-frame/data-frame-row-slice

But with no luck How do i do the above?

Upvotes: 0

Views: 117

Answers (1)

Jilber Urbina
Jilber Urbina

Reputation: 61154

Try

data[20:50, ]

this will give you rows from 20 to 50. Take a look at ?"["

Upvotes: 3

Related Questions