[R] combine filter() and select()
Ivan Calandra
c@|@ndr@ @end|ng |rom rgzm@de
Wed Aug 19 16:56:32 CEST 2020
Dear useRs,
I'm new to the tidyverse world and I need some help on basic things.
I have the following tibble:
mytbl <- structure(list(files = c("a", "b", "c", "d", "e", "f"), prop =
1:6), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))
I want to subset the rows with "a" in the column "files", and keep only
that column.
So I did:
myfile <- mytbl %>%
filter(grepl("a", files)) %>%
select(files)
It works, but I believe there must be an easier way to combine filter()
and select(), right?
Thank you!
Ivan
--
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra
More information about the R-help
mailing list