Description Usage Arguments Details Value Author(s) Examples
Uses a codebook which is an S3 class codebook
, possibly
read in by read_codebook
, to convert numerical vectors into
factors
in a tibble
.
1 | create_factors(x, code_book, column_names = NULL)
|
x |
|
code_book |
|
column_names |
character vector of column names for conversion to
factors. Default: All |
REPEAT: Often, when analysing data, data dictionaries or code books are
provided with data files. Rather than a word
doc
or
pdf
files, the format required here is in a very specific
format stored as a csv
file. Once read in, attributes such
as factor labels/levels and variable labels can be added to the
data.frame
and/or also used to check factor labels and
variable names are consistent with the code book. Note that while
various methods may be available which attempt to convert word
docs or pdf's to a spreadsheet and/or csv file, extreme care
should be taken as these are far from perfect.
object of type class tibble
Peter Baker pete@petebaker.id.au
1 2 3 4 5 6 7 8 9 10 11 12 | file.copy(system.file('demoFiles', 'data1_codebook.csv',
package='codebookr'), 'data1_codebook.csv')
file.copy(system.file('demoFiles', 'data1-birth.csv',
package='codebookr'), 'data1-birth.csv')
data1_codebook <- read_codebook("data1_codebook.csv",
column_names = list(variable_levels = "Factor.Levels",
variable_original = "Old.Variable",
min = "Min", max = "Max"))
data1 <- readr::read_csv('data1-birth.csv')
data1
myData <- create_factors(data1, data1_codebook)
str(myData)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.