How to select just 10 observations from a R dataset

The first line creates a sequence variable.  The second like selects the first 30 observations.

smalldata$suji <- 1:nrow(smalldata)
smalldata<-filter(smalldata,suji <= 30)

In SAS's datastep, this would be:

suji=_n_;

if suji <=30;

 

CategoriesR

Leave a Reply