readDataDict {exceldata}R Documentation

Read in the data dictionary

Description

This function reads in a data dictionary from an Excel file, based on the Excel DataDictionary template

Usage

readDataDict(
  excelFile,
  dictionarySheet = "DataDictionary",
  range,
  colnames,
  origin
)

Arguments

excelFile

Character, Path and Name of the data file

dictionarySheet

Character, Name of the dictionary sheet within the file, defaults to 'DataDictionary'

range

Optional, Range of Excel sheet to restrict import to (ie. range="A1:F6")

colnames

Optional, Column names of the dictionary, defaults to those used in the Excel template: c('VariableName', 'Description (optional)', 'Type', 'Minimum', 'Maximum', 'Levels')

origin

Optional, the date origin of Excel dates, defaults to 30 December 1899

Details

It assumes that the columns names have not been altered and are: c('VariableName', 'Description (optional)', 'Type', 'Minimum', 'Maximum', 'Levels')

To override these column names specify colnames as an argument, ensuring that the content of the columns is in the above order. As of the time of writing, the origin date in Excel is 30 December 1899. To override this specify origin="yyy-mm-dd"

To read in only part of the excel sheet specify the desired range (ie range="A1:F6")

Value

A data frame with an entry for each variable to be imported

Examples

exampleDataFile <- system.file("extdata", "exampleData.xlsx", package = "exceldata")
dictionary <- readDataDict(exampleDataFile, dictionarySheet = 'DataDictionary')

[Package exceldata version 0.1.1.3 Index]