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, and *.mbox 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: read_csv for CSV (Comma-Separated Values) files; read_csv2 for CSV2 (Semicolon-Separated Values) files; read_tsv for 'TSV' (Tab-Separated Values) files; read_file for '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; 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.

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) # Now you can use the imported file as a tibble. str(data)
#> Classes 'tbl_df', 'tbl' and 'data.frame': 153 obs. of 6 variables: #> $ Ozone : num 41 36 12 18 NA 28 23 19 8 NA ... #> ..- attr(*, "format.spss")= chr "F8.0" #> $ Solar.R: num 190 118 149 313 NA NA 299 99 19 194 ... #> ..- attr(*, "format.spss")= chr "F8.0" #> $ Wind : num 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 67 72 74 62 56 66 65 59 61 69 ... #> ..- attr(*, "format.spss")= chr "F8.0" #> $ Month : num 5 5 5 5 5 5 5 5 5 5 ... #> ..- attr(*, "format.spss")= chr "F8.0" #> $ Day : num 1 2 3 4 5 6 7 8 9 10 ... #> ..- attr(*, "format.spss")= chr "F8.0"