Skip to contents

Convert the numeric, boolean and Date/time columns of a dataset xs:decimal, xsLboolean, xs:date and xs:dateTime.

Usage

xsd_convert(x, idcol, ...)

# S3 method for data.frame
xsd_convert(x, idcol = NULL, ...)

# S3 method for dataset
xsd_convert(x, idcol = NULL, ...)

# S3 method for tibble
xsd_convert(x, idcol = NULL, ...)

# S3 method for character
xsd_convert(x, idcol = NULL, ...)

# S3 method for numeric
xsd_convert(x, idcol = NULL, ...)

# S3 method for integer
xsd_convert(x, idcol = NULL, ...)

# S3 method for boolean
xsd_convert(x, idcol = NULL, ...)

# S3 method for factor
xsd_convert(x, idcol = NULL, ...)

# S3 method for POSIXct
xsd_convert(x, idcol = NULL, ...)

# S3 method for Date
xsd_convert(x, idcol = NULL, ...)

Arguments

x

An R object that contains the data of the dataset (a data.frame or inherited from data.frame), for example, tibble::tibble(), tsibble::tsibble(), data.table::data.table().

idcol

The name or position of the column that contains the row (observation) identifiers. If NULL, it will make a new idcol from row.names().

...

Further optional parameters for generic method.

See also

Examples


# Convert data.frame to XML Schema Definition
xsd_convert(head(iris))
#>          Sepal.Length         Sepal.Width        Petal.Length
#> 1 "5.1"^^<xs:decimal> "3.5"^^<xs:decimal> "1.4"^^<xs:decimal>
#> 2 "4.9"^^<xs:decimal>   "3"^^<xs:decimal> "1.4"^^<xs:decimal>
#> 3 "4.7"^^<xs:decimal> "3.2"^^<xs:decimal> "1.3"^^<xs:decimal>
#> 4 "4.6"^^<xs:decimal> "3.1"^^<xs:decimal> "1.5"^^<xs:decimal>
#> 5   "5"^^<xs:decimal> "3.6"^^<xs:decimal> "1.4"^^<xs:decimal>
#> 6 "5.4"^^<xs:decimal> "3.9"^^<xs:decimal> "1.7"^^<xs:decimal>
#>           Petal.Width               Species
#> 1 "0.2"^^<xs:decimal> "setosa"^^<xs:string>
#> 2 "0.2"^^<xs:decimal> "setosa"^^<xs:string>
#> 3 "0.2"^^<xs:decimal> "setosa"^^<xs:string>
#> 4 "0.2"^^<xs:decimal> "setosa"^^<xs:string>
#> 5 "0.2"^^<xs:decimal> "setosa"^^<xs:string>
#> 6 "0.4"^^<xs:decimal> "setosa"^^<xs:string>

# Convert dataset to XML Schema Definition
xsd_convert(head(iris_dataset))
#> Anderson E (1935). "Iris Dataset [subset]."
#>                Sepal.Length         Sepal.Width        Petal.Length
#> iris:o1 "5.1"^^<xs:decimal> "3.5"^^<xs:decimal> "1.4"^^<xs:decimal>
#> iris:o2 "4.9"^^<xs:decimal>   "3"^^<xs:decimal> "1.4"^^<xs:decimal>
#> iris:o3 "4.7"^^<xs:decimal> "3.2"^^<xs:decimal> "1.3"^^<xs:decimal>
#> iris:o4 "4.6"^^<xs:decimal> "3.1"^^<xs:decimal> "1.5"^^<xs:decimal>
#> iris:o5   "5"^^<xs:decimal> "3.6"^^<xs:decimal> "1.4"^^<xs:decimal>
#> iris:o6 "5.4"^^<xs:decimal> "3.9"^^<xs:decimal> "1.7"^^<xs:decimal>
#>                 Petal.Width               Species
#> iris:o1 "0.2"^^<xs:decimal> "setosa"^^<xs:string>
#> iris:o2 "0.2"^^<xs:decimal> "setosa"^^<xs:string>
#> iris:o3 "0.2"^^<xs:decimal> "setosa"^^<xs:string>
#> iris:o4 "0.2"^^<xs:decimal> "setosa"^^<xs:string>
#> iris:o5 "0.2"^^<xs:decimal> "setosa"^^<xs:string>
#> iris:o6 "0.4"^^<xs:decimal> "setosa"^^<xs:string>
#> Further metadata: describe(x)