These methods allow more complex selection criteria than select_datasets and family, which only use the identifier values. These methods first subset the required table using the provided expression, then subset other tables to ensure internal consistency.
filter_datasets(.data, ...) # S3 method for default filter_datasets(.data, ...) filter_data(.data, ...) # S3 method for default filter_data(.data, ...) filter_locations(.data, ...) # S3 method for default filter_locations(.data, ...) filter_params(.data, ...) # S3 method for default filter_params(.data, ...)
.data | A mudata object |
---|---|
... | Objects passed to filter on the appropriate table |
A subsetted mudata object
# select only locations with a latitude above 45 ns_climate %>% filter_locations(latitude > 45)#> A mudata object aligned along "date" #> distinct_datasets(): "ecclimate_monthly" #> distinct_locations(): "BADDECK 6297", "COLLEGEVILLE 6329" ... and 5 more #> distinct_params(): "extr_max_temp", "extr_min_temp" ... and 7 more #> src_tbls(): "data", "locations" ... and 3 more #> #> tbl_data() %>% head(): #> # A tibble: 6 x 7 #> dataset location param date value flag flag_text #> <chr> <chr> <chr> <date> <dbl> <chr> <chr> #> 1 ecclimate_monthly BADDECK 6297 mean_max_temp 1876-01-01 -4.7 <NA> <NA> #> 2 ecclimate_monthly BADDECK 6297 mean_max_temp 1876-02-01 -2.1 <NA> <NA> #> 3 ecclimate_monthly BADDECK 6297 mean_max_temp 1876-03-01 1.2 <NA> <NA> #> 4 ecclimate_monthly BADDECK 6297 mean_max_temp 1876-04-01 5.1 <NA> <NA> #> 5 ecclimate_monthly BADDECK 6297 mean_max_temp 1876-05-01 11.9 <NA> <NA> #> 6 ecclimate_monthly BADDECK 6297 mean_max_temp 1876-06-01 21.3 <NA> <NA># select only params measured in mm ns_climate %>% filter_params(unit == "mm")#> A mudata object aligned along "date" #> distinct_datasets(): "ecclimate_monthly" #> distinct_locations(): "ANNAPOLIS ROYAL 6289", "BADDECK 6297" ... and 13 more #> distinct_params(): "total_precip", "total_rain" #> src_tbls(): "data", "locations" ... and 3 more #> #> tbl_data() %>% head(): #> # A tibble: 6 x 7 #> dataset location param date value flag flag_text #> <chr> <chr> <chr> <date> <dbl> <chr> <chr> #> 1 ecclimate_monthly SABLE ISLAND 6454 total_ra… 1891-01-01 NA M Missing #> 2 ecclimate_monthly SABLE ISLAND 6454 total_ra… 1891-02-01 40.4 <NA> <NA> #> 3 ecclimate_monthly SABLE ISLAND 6454 total_ra… 1891-03-01 32 <NA> <NA> #> 4 ecclimate_monthly SABLE ISLAND 6454 total_ra… 1891-04-01 132. <NA> <NA> #> 5 ecclimate_monthly SABLE ISLAND 6454 total_ra… 1891-05-01 44.7 <NA> <NA> #> 6 ecclimate_monthly SABLE ISLAND 6454 total_ra… 1891-06-01 106. <NA> <NA>#> #>#>#> #>#> A mudata object aligned along "date" #> distinct_datasets(): "ecclimate_monthly" #> distinct_locations(): "ANNAPOLIS ROYAL 6289", "BADDECK 6297" ... and 13 more #> distinct_params(): "dir_of_max_gust", "extr_max_temp" ... and 9 more #> src_tbls(): "data", "locations" ... and 3 more #> #> tbl_data() %>% head(): #> # A tibble: 6 x 7 #> dataset location param date value flag flag_text #> <chr> <chr> <chr> <date> <dbl> <chr> <chr> #> 1 ecclimate_month… SABLE ISLAND 64… mean_max_t… 1897-06-01 NA M Missing #> 2 ecclimate_month… SABLE ISLAND 64… mean_max_t… 1898-06-01 13.4 <NA> <NA> #> 3 ecclimate_month… SABLE ISLAND 64… mean_max_t… 1899-06-01 14.4 <NA> <NA> #> 4 ecclimate_month… SABLE ISLAND 64… mean_max_t… 1900-06-01 14.6 <NA> <NA> #> 5 ecclimate_month… SABLE ISLAND 64… mean_max_t… 1901-06-01 15.3 <NA> <NA> #> 6 ecclimate_month… SABLE ISLAND 64… mean_max_t… 1902-06-01 13.6 <NA> <NA>