Skip to contents

[Experimental] Please note that the script has to end with a call creating desired object. The error will be raised otherwise.

Usage

teal_data_file(path, code = get_code(path))

Arguments

path

A (connection) or a (character)
string giving the pathname of the file or URL to read from. "" indicates the connection stdin.

code

(character)
reproducible code to re-create object

Value

TealData object

Examples

# simple example
file_example <- tempfile(fileext = ".R")
writeLines(
  text = c(
    "library(teal.data)

     x1 <- dataset(dataname = \"IRIS\",
                   x = iris,
                   code = \"IRIS <- iris\")

     x2 <- dataset(dataname = \"MTCARS\",
                   x = mtcars,
                   code = \"MTCARS <- mtcars\")

     teal_data(x1, x2)"
  ),
  con = file_example
)
teal_data_file(file_example, code = character(0))
#> A TealData object containing 2 TealDataset/TealDatasetConnector object(s) as element(s):
#> --> Element 1:
#> A TealDataset object containing the following data.frame (150 rows and 5 columns):
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          5.1         3.5          1.4         0.2  setosa
#> 2          4.9         3.0          1.4         0.2  setosa
#> 3          4.7         3.2          1.3         0.2  setosa
#> 4          4.6         3.1          1.5         0.2  setosa
#> 5          5.0         3.6          1.4         0.2  setosa
#> 6          5.4         3.9          1.7         0.4  setosa
#> 
#> ...
#>     Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
#> 145          6.7         3.3          5.7         2.5 virginica
#> 146          6.7         3.0          5.2         2.3 virginica
#> 147          6.3         2.5          5.0         1.9 virginica
#> 148          6.5         3.0          5.2         2.0 virginica
#> 149          6.2         3.4          5.4         2.3 virginica
#> 150          5.9         3.0          5.1         1.8 virginica
#> --> Element 2:
#> A TealDataset object containing the following data.frame (32 rows and 11 columns):
#>                    mpg cyl disp  hp drat    wt  qsec vs am gear carb
#> Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
#> Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
#> Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
#> Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
#> Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
#> Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1
#> 
#> ...
#>                 mpg cyl  disp  hp drat    wt qsec vs am gear carb
#> Porsche 914-2  26.0   4 120.3  91 4.43 2.140 16.7  0  1    5    2
#> Lotus Europa   30.4   4  95.1 113 3.77 1.513 16.9  1  1    5    2
#> Ford Pantera L 15.8   8 351.0 264 4.22 3.170 14.5  0  1    5    4
#> Ferrari Dino   19.7   6 145.0 175 3.62 2.770 15.5  0  1    5    6
#> Maserati Bora  15.0   8 301.0 335 3.54 3.570 14.6  0  1    5    8
#> Volvo 142E     21.4   4 121.0 109 4.11 2.780 18.6  1  1    4    2