Reputation: 15363
Consider the following code:
baseball <- read.csv("c:\\Users\\Jim\\Downloads\\MLB2008.csv", header = T)
baseball[1:70,]
This code will print out the first 70 rows of the data frame named 'baseball'.
How can I do this?
Upvotes: 1
Views: 2533
Reputation: 13570
Using head
and tail
.
head(baseball, round(nrow(baseball)*0.7))
tail(baseball, round(nrow(baseball)*0.3))
Upvotes: 4
Reputation: 4024
cutoff = round(0.7*nrow(baseball))
baseball[1:cutoff,]
baseball[-(1:cutoff),]
Upvotes: 3