Last data update: 2014.03.03

R: Read in Blaise data models
read_dm_blaiseR Documentation

Read in Blaise data models

Description

Read in Blaise data models

Usage

read_dm_blaise(filename, datafilename = NA)

Arguments

filename

the filename of the file containing the data model.

datafilename

the filename of the data file to which the data model belongs.

Details

The function reads the data model from file and returns a list that can be used by laf_open to open the file for reading. Only a subset of the most common features found in Blaise files are supported. If part of the data model can not be parsed a warning is given.

Value

Returns a data model (which is a list containing all the relevant information to open a file using laf_open. When the file contains more than one data model a list of data models is returned and a warning issued.

See Also

See write_dm to write the data model to file. The data models can be used to open a file using laf_open.

Examples

# Generate test data
lines <- c(
    " 1M 1.45Rotterdam ",
    " 2F12.00Amsterdam ",
    " 3  .22 Berlin    ",
    "  M22   Paris     ",
    " 4F12345London    ",
    " 5M     Copenhagen",
    " 6M-12.1          ",
    " 7F   -1Oslo      ")
writeLines(lines, con="tmp.dat")

# Create a file containing the data model
writeLines(c(
    "DATAMODEL test",
    "FIELDS",
    "  id     : INTEGER[2]",
    "  gender : STRING[1]",
    "  x      : REAL[5] {comment}",
    "  city   : STRING[10]",
    "ENDMODEL"), con="tmp.bla")
model <- read_dm_blaise("tmp.bla", datafilename="tmp.dat")
laf <- laf_open(model)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(LaF)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LaF/read_dm_blaise.Rd_%03d_medium.png", width=480, height=480)
> ### Name: read_dm_blaise
> ### Title: Read in Blaise data models
> ### Aliases: read_dm_blaise
> 
> ### ** Examples
> 
> # Generate test data
> lines <- c(
+     " 1M 1.45Rotterdam ",
+     " 2F12.00Amsterdam ",
+     " 3  .22 Berlin    ",
+     "  M22   Paris     ",
+     " 4F12345London    ",
+     " 5M     Copenhagen",
+     " 6M-12.1          ",
+     " 7F   -1Oslo      ")
> writeLines(lines, con="tmp.dat")
> 
> # Create a file containing the data model
> writeLines(c(
+     "DATAMODEL test",
+     "FIELDS",
+     "  id     : INTEGER[2]",
+     "  gender : STRING[1]",
+     "  x      : REAL[5] {comment}",
+     "  city   : STRING[10]",
+     "ENDMODEL"), con="tmp.bla")
> model <- read_dm_blaise("tmp.bla", datafilename="tmp.dat")
> laf <- laf_open(model)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>