[R] How to select rows, not in sequence

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Sat Jul 24 13:50:57 CEST 2021


Hello,

Simply by also passing a vector to the extraction function:


rows= df[c(1,2,5,7,12) , ]


Hope this helps,

Rui Barradas

Às 12:38 de 24/07/21, Neha gupta escreveu:
> Hi
> 
> If I have to select specific rows and all columns of a dataframe, I use:
> 
> rows= df[1:12 , ]
> 
> However, how to select rows if our required rows are not in sequence i.e.
> if we need to select row numbers 1,2,5,7, and 12..
> 
> Warm regards
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list