Skip to content

Commit

Permalink
code reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
aammd committed Feb 27, 2017
1 parent ac6d71f commit ebc0d55
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions gap_eml.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ library(dplyr)
library(EML)
library(gapminder)

## could also be done:

# attributes --------------------------------------------------------------

attributes <- frame_data(
~attributeName, ~formatString, ~definition , ~unit, ~numberType, ~attributeDefinition,
"country" , NA, "country", NA, NA, "name of country",
Expand All @@ -14,12 +16,15 @@ attributes <- frame_data(
"gdpPercap" , NA, NA, "number", "real", "GDP per capita"
)

## what units can we use? consult
## what units can we use? consult:
# standardUnits <- get_unitList()
# standardUnits$units
# View(standardUnits$units)

## now for the factors:

# factors -----------------------------------------------------------------

## there are no factors in this dataset, but this is where you would put them!

attributeList <- set_attributes(as.data.frame(attributes),
col_classes = c("character", "character",
Expand All @@ -28,7 +33,10 @@ attributeList <- set_attributes(as.data.frame(attributes),
## as many col_classes as there are rows in attributes
## note that you need to coerce attributes back to data.frame

glimpse(attributes)

# dataTable: putting it together ------------------------------------------



readr::write_csv(gapminder, "data/gapminder.csv")
physical <- set_physical("data/gapminder.csv")
Expand All @@ -39,10 +47,28 @@ dataTable <- new("dataTable",
physical = physical,
attributeList = attributeList)


# person ------------------------------------------------------------------



R_person <- as.person("John Doe <[email protected]")
ownername <-as(R_person, "creator")


contact <-
new("contact",
individualName = ownername@individualName,
electronicMail = ownername@electronicMailAddress,
# address =,
organizationName = "Gapminder",
phone = "000-000-0000")



# coverage ----------------------------------------------------------------


coverage <-
set_coverage(begin = '1952-01-01', end = '2007-01-01',
geographicDescription = "The world",
Expand All @@ -51,13 +77,8 @@ coverage <-
altitudeMin = 0, altitudeMaximum = 2000,
altitudeUnits = "meter")

contact <-
new("contact",
individualName = ownername@individualName,
electronicMail = ownername@electronicMailAddress,
# address =,
organizationName = "Gapminder",
phone = "000-000-0000")

# combining everything: dataset -------------------------------------------


dataset <- new("dataset",
Expand Down

0 comments on commit ebc0d55

Please sign in to comment.