genMoreInfo {googlePublicData} | R Documentation |
Generates a dataframe used to complement a DSPL bundle
Description
Parsing csv, tab or xls(x) files at a specific directory path, genMore info generates a dataframe used to complete a DSPL bundle with a more complete concepts definition including description, url, etc..
Usage
genMoreInfo(path, encoding = getOption("encoding"), sep = ";",
output = NA, action = "merge", dec = ".")
Arguments
path |
String. Path to the folder where the tables are saved. |
encoding |
The encoding of the files to be parsed. |
sep |
The separation character of the tables in the 'path' folder. Currently supports introducing the following arguments: “,” or “;” (for .csv files), “\t” (for .tab files) and “xls” or “xlsx” (for Microsoft's excel files). |
output |
If defined, the place where to save the dataframe as tab file. Otherwise it returns a data frame object. |
action |
Tells the function what to do if there's a copy of the file. Available actions are “merge” and “replace”. |
dec |
String. Decimal point. |
Details
If there isn't any output defined (NA
) the function returns a
dataframe containing concepts as observations. Using this, the user may add
more descriptive info about concepts. In turn it writes a tab file with the
dataframe described above. The user may recycle this file writing “append”
in the action
argument.
Value
If no output
defined, genMoreInfo
returns a dataframe
with the following columns.
id |
XML id of the concept (autogenerated) |
label |
The label of the concept (autogenerated) |
description |
A brief description of the concept |
topic |
The topic of the concept |
url |
A URL for the concept where, for example, to get more info |
totalName |
A total name as specified by DSPL language (works for dimensional concepts) |
pluralName |
A total name as specified by DSPL language (works for dimensional concepts) |
Author(s)
George G. Vega Yon
References
Google Public Data Explorer: http://publicdata.google.com
Examples
# Getting the path where all the datasets are
path <- system.file("dspl-tutorial", package="googlePublicData")
info <- genMoreInfo(path) # This is a dataframe
# Setting the 5th concept as topic "Demographics"
info[5, "topic"] <- "Demographics"
# Generating the dspl file
ans <- dspl(path, moreinfo = info)
ans
## Not run:
# Parsing some xlsx files at "my stats folder" to gen a "moreinfo" dataframe
INFO <- genMoreInfo(path="my stats folder/", sep="xls")
# Rows 1 to 10 are about "Poverty" and rows 11 to 20 about "Education"
# So we fill the "topic" column with it.
INFO$topic[1:10] <- "Poverty"
INFO$topic[11:20] <- "Education"
# Finally, we build the DSPL ZIP including more info
dspl(path="my stats folder/", sep="xls", moreinfo=INFO)
## End(Not run)