These functions wrap common use-cases of list_any().

list_csv(
  path = ".",
  regexp = "[.]csv$",
  ignore.case = TRUE,
  invert = FALSE,
  ...
)

list_tsv(
  path = ".",
  regexp = "[.]tsv$",
  ignore.case = TRUE,
  invert = FALSE,
  ...
)

list_rds(path = ".", regexp = "[.]rds$", ignore.case = TRUE, invert = FALSE)

list_rdata(
  path = ".",
  regexp = "[.]rdata$|[.]rda$",
  ignore.case = TRUE,
  invert = FALSE
)

Arguments

path

A character vector of one path. Defaults to the working directory.

regexp

A regular expression (e.g. [.]csv$) passed on to grep() to filter paths.

ignore.case

if FALSE, the pattern matching is case sensitive and if TRUE, case is ignored during matching.

invert

If TRUE return files which do not match

...

Arguments passed to readr::read_csv() or readr::read_tsv().

Value

A list.

See also

Other functions to import files into a list: list_any()

Other functions to import files of common formats: load_csv()

Examples

(rds <- tor_example("rds"))
#> [1] "/home/runner/work/_temp/Library/tor/extdata/rds"
dir(rds)
#> [1] "rds1.rds" "rds2.rds"
list_rds(rds)
#> $rds1 #> # A tibble: 2 × 1 #> x #> <dbl> #> 1 1 #> 2 2 #> #> $rds2 #> # A tibble: 2 × 1 #> y #> <chr> #> 1 a #> 2 b #>
(tsv <- tor_example("tsv"))
#> [1] "/home/runner/work/_temp/Library/tor/extdata/tsv"
dir(tsv)
#> [1] "tsv1.tsv" "tsv2.tsv"
list_tsv(tsv)
#> Rows: 3 Columns: 2
#> ── Column specification ──────────────────────────────────────────────────────── #> Delimiter: "\t" #> chr (1): y #> dbl (1): x
#> #> Use `spec()` to retrieve the full column specification for this data. #> Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 3 Columns: 2
#> ── Column specification ──────────────────────────────────────────────────────── #> Delimiter: "\t" #> chr (1): y #> dbl (1): x
#> #> Use `spec()` to retrieve the full column specification for this data. #> Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> $tsv1 #> # A tibble: 3 × 2 #> x y #> <dbl> <chr> #> 1 1 a #> 2 2 NA #> 3 3 NA #> #> $tsv2 #> # A tibble: 3 × 2 #> x y #> <dbl> <chr> #> 1 1 a #> 2 2 NA #> 3 3 b #>
(mixed <- tor_example("mixed"))
#> [1] "/home/runner/work/_temp/Library/tor/extdata/mixed"
dir(mixed)
#> [1] "csv.csv" "lower_rdata.rdata" "rda.rda" #> [4] "upper_rdata.RData"
list_rdata(mixed)
#> $lower_rdata #> # A tibble: 2 × 1 #> y #> <chr> #> 1 a #> 2 b #> #> $rda #> # A tibble: 2 × 1 #> y #> <chr> #> 1 a #> 2 b #> #> $upper_rdata #> # A tibble: 2 × 1 #> y #> <chr> #> 1 a #> 2 b #>
list_csv(mixed)
#> Rows: 2 Columns: 1
#> ── Column specification ──────────────────────────────────────────────────────── #> Delimiter: "," #> chr (1): y
#> #> Use `spec()` to retrieve the full column specification for this data. #> Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> $csv #> # A tibble: 2 × 1 #> y #> <chr> #> 1 a #> 2 b #>
list_rdata(mixed, regexp = "[.]RData", ignore.case = FALSE)
#> $upper_rdata #> # A tibble: 2 × 1 #> y #> <chr> #> 1 a #> 2 b #>