R: How to select not continous rows? – Education Career Blog

How can I select several not continuous rows ?

If I wanted to select rows 1 to 7 I’ll write
mydata,1:7

But what if I need to select rows 1 to 5 and 10 to 15?

,

Briefly:

  1. Your example is wrong, you selected columns. You meant mydata1:7,
  2. The generalisation is easy: change the indexing expression as in mydata c(1:5, 10:15),

You may want to acquaint yourself with the An Introduction to R manual that came with your R installation to learn more about indexing.

,

mydata:,range(1,6)+range(10,16). In python a suppose.

Leave a Comment