You can alternatively use this function for choosing *.csv, *.csv2, *.tsv, *.txt, *.xls, *.xlsx, *.json, *.html, *.htm, *.php, *.pdf, *.doc, *.docx, *.rtf, *.RData, *.Rda, *.RDS, *.sav (SPSS), *.por, *.sas7bdat, *.sas7bcat, *.dta, *.xpt, *.mbox, and *.Rmd files in an interactive GUI mode A file choose dialog box will be prompted.

pick(file = NULL, mode = NULL, ...)

Arguments

file

Either a path to a file, a connection, or literal data (either a single string or a raw vector). The default is NULL, which pops up an interactive GUI file choose dialogue box for users unless an explicit path/to/filename is given. Each corresponding function depending upon a file extension will be automatically matched and applied once you pick up your file using either the GUI-file-chooser dialog box or explicit path/to/filename.

mode

Character value for session locale and encoding; available values are: "ko1" for "CP949"; "ko2" for "UTF-8" while both change R locale into Korean (default is the current locale and encoding of your R session).

...

Any additional arguments available for each file type and extension: vroom for 'CSV' (Comma-Separated Values); 'CSV2' (Semicolon-Separated Values); 'TSV' (Tab-Separated Values); 'txt' (plain text) files; read_excel for 'Excel' files; read_spss for 'SPSS' files; read_stata for 'Stata' files; read_sas for 'SAS' files; read_document for 'Microsoft Word', 'PDF', 'RTF', 'HTML', 'HTM', and 'PHP' files; fromJSON for 'JSON' files; read_mbox for 'mbox' files; render for 'Rmd' files; source for 'R' files; readRDS for 'RDS' files; load for 'RDA' and 'RDATA' files.

Value

tibble (table data.frame) object of the chosen rectangular data file will be returned.

Details

pick

See example below.

See also

picko for Korean users.

Author

JooYoung Seo, jooyoung@psu.edu

Soyoung Choi, sxc940@psu.edu

Examples

# Choosing file and saving it into a variable
## Scenario 1: Picking up a file using interactive GUI dialog box:
if (interactive()) {
  library(ezpickr)
  ## Use either `pick(mode="ko1")` or `pick(mode="ko2")` for Korean R users.
  data <- pick()
}

## Scenario 2: Picking up a file using an explicit file name ("test.sav" in the example below;
## however, you can feed other files through this function
## such as *.SAS, *.DTA, *.csv, *.csv2, *.tsv, *.xlsx, *.txt,
## *.html, webpage URL, *doc, *.docx, *.pdf, *.rtf, *.json, *.Rda, *.Rdata, and more):
library(ezpickr)
test <- system.file("extdata", "airquality.sav", package = "ezpickr")
## Use either `pick(test, mode="ko1")` or `pick(test, mode="ko2")` for Korean R users.
data <- pick(test)
#> Registered S3 methods overwritten by 'readr':
#>   method                    from 
#>   as.data.frame.spec_tbl_df vroom
#>   as_tibble.spec_tbl_df     vroom
#>   format.col_spec           vroom
#>   print.col_spec            vroom
#>   print.collector           vroom
#>   print.date_names          vroom
#>   print.locale              vroom
#>   str.col_spec              vroom

# Now you can use the imported file as a tibble.
str(data)
#> tibble [153 × 6] (S3: tbl_df/tbl/data.frame)
#>  $ Ozone  : num [1:153] 41 36 12 18 NA 28 23 19 8 NA ...
#>   ..- attr(*, "format.spss")= chr "F8.0"
#>  $ Solar.R: num [1:153] 190 118 149 313 NA NA 299 99 19 194 ...
#>   ..- attr(*, "format.spss")= chr "F8.0"
#>  $ Wind   : num [1:153] 7.4 8 12.6 11.5 14.3 14.9 8.6 13.8 20.1 8.6 ...
#>   ..- attr(*, "format.spss")= chr "F8.2"
#>  $ Temp   : num [1:153] 67 72 74 62 56 66 65 59 61 69 ...
#>   ..- attr(*, "format.spss")= chr "F8.0"
#>  $ Month  : num [1:153] 5 5 5 5 5 5 5 5 5 5 ...
#>   ..- attr(*, "format.spss")= chr "F8.0"
#>  $ Day    : num [1:153] 1 2 3 4 5 6 7 8 9 10 ...
#>   ..- attr(*, "format.spss")= chr "F8.0"