Skip to contents

Write a dataset into a Turtle serialisation.

Usage

dataset_ttl_write(
  tdf,
  ttl_namespace = NULL,
  file_path = NULL,
  overwrite = TRUE
)

Arguments

tdf

A dataset in exactly three columns.

ttl_namespace

The namespace definitions of the dataset.

file_path

The path to the file that should be written or appended.

overwrite

If the file exists, overwrite it? Defaults to TRUE.

Value

A text file with the prefix and the observation serialisations.

Examples

testtdf <- data.frame (s = c("eg:o1", "eg:01", "eg:02"),
                       p = c("a", "eg-var:", "eg-var"),
                       o = c("qb:Observation",
                             "\"1\"^^<xs:decimal>",
                             "\"2\"^^<xs:decimal>"))

examplefile <- file.path(tempdir(), "ttl_dataset_write.ttl")

dataset_ttl_write(tdf=testtdf, file_path = examplefile)

readLines(examplefile)
#>  [1] "@prefix  owl:        <http://www.w3.org/2002/07/owl#> ."             
#>  [2] "@prefix  qb:         <http://purl.org/linked-data/cube#> ."          
#>  [3] "@prefix  rdf:        <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ."
#>  [4] "@prefix  rdfs:       <http://www.w3.org/2000/01/rdf-schema#> ."      
#>  [5] "@prefix  xsd:        <http://www.w3.org/2001/XMLSchema#> ."          
#>  [6] ""                                                                    
#>  [7] "# -- Observations -----------------------------------------"         
#>  [8] ""                                                                    
#>  [9] "eg:o1 a qb:Observation ;"                                            
#> [10] "   a   qb:Observation ;"                                             
#> [11] "   ."                                                                
#> [12] "eg:01 a qb:Observation ;"                                            
#> [13] "   eg-var:   \"1\"^^<xs:decimal> ;"                                  
#> [14] "   ."                                                                
#> [15] "eg:02 a qb:Observation ;"                                            
#> [16] "   eg-var   \"2\"^^<xs:decimal> ;"                                   
#> [17] "   ."