Create a source object.
datasource( file, skip = 0, skip_empty_rows = FALSE, comment = "", skip_quote = TRUE )
| file | Either a path to a file, a connection, or literal data (either a single string or a raw vector). Files ending in Literal data is most useful for examples and tests. It must contain at least one new line to be recognised as data (instead of a path) or be a vector of greater than length 1. Using a value of |
|---|---|
| skip | Number of lines to skip before reading data. |
# Literal csv datasource("a,b,c\n1,2,3")#> [[1]] #> [1] "a,b,c\n1,2,3" #> #> $skip #> [1] 0 #> #> $skip_empty_rows #> [1] FALSE #> #> $comment #> [1] "" #> #> $skip_quote #> [1] TRUE #> #> attr(,"class") #> [1] "source_string" "source"#> [[1]] #> [1] 61 2c 62 2c 63 0a 31 2c 32 2c 33 #> #> $skip #> [1] 0 #> #> $skip_empty_rows #> [1] FALSE #> #> $comment #> [1] "" #> #> $skip_quote #> [1] TRUE #> #> attr(,"class") #> [1] "source_raw" "source"#> [[1]] #> [1] "/data/GHE/mpn/deployment/deployments/2020-10-26/renv/library/R-3.6/x86_64-pc-linux-gnu/readr/extdata/mtcars.csv" #> #> $skip #> [1] 0 #> #> $skip_empty_rows #> [1] FALSE #> #> $comment #> [1] "" #> #> $skip_quote #> [1] TRUE #> #> attr(,"class") #> [1] "source_file" "source"#> [[1]] #> [1] "/tmp/RtmpMNsXxw/file609f61227d6b" #> #> $skip #> [1] 0 #> #> $skip_empty_rows #> [1] FALSE #> #> $comment #> [1] "" #> #> $skip_quote #> [1] TRUE #> #> $env #> <environment: 0x55cb9f525e78> #> #> attr(,"class") #> [1] "source_file" "source"#> [[1]] #> [1] "/tmp/RtmpMNsXxw/file609f2846cfd1" #> #> $skip #> [1] 0 #> #> $skip_empty_rows #> [1] FALSE #> #> $comment #> [1] "" #> #> $skip_quote #> [1] TRUE #> #> $env #> <environment: 0x55cb9f5bed88> #> #> attr(,"class") #> [1] "source_file" "source"if (FALSE) { datasource("https://github.com/tidyverse/readr/raw/master/inst/extdata/mtcars.csv") } # Connection con <- rawConnection(charToRaw("abc\n123")) datasource(con)#> [[1]] #> [1] "/tmp/RtmpMNsXxw/file609f3fd0af11" #> #> $skip #> [1] 0 #> #> $skip_empty_rows #> [1] FALSE #> #> $comment #> [1] "" #> #> $skip_quote #> [1] TRUE #> #> $env #> <environment: 0x55cb9f69b770> #> #> attr(,"class") #> [1] "source_file" "source"