Hello everyone. I’m a bit novice to R Studio. I have a data set titled rent.US. Let’s say I want to select 3 rows and 2 columns from this data set at the same time, how would I do that? Thank you
Using mtcars
as an example for subset by position
mtcars[1:3,4:5]
#> hp drat
#> Mazda RX4 110 3.90
#> Mazda RX4 Wag 110 3.90
#> Datsun 710 93 3.85
Created on 2020-09-10 by the reprex package (v0.3.0)
Columns can also be selected by name, using the dplyr
package
mtcars %>% select(hp,drat) -> result
That result can be subset by row position with
result[1:3,]
1 Like
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.