codebook: Codebook

View source: R/codebook.R

codebookR Documentation

Codebook

Description

codebook: Create a structure of the data as data.frame.

use_codebook: Restore the structure of the data from the Excel file created by the Codebook function.

save_data: Write an Excel or SPSS file.

Usage

codebook(x)

save_codebook(x, file = "codebook.xlsx")

use_codebook(
  data = NULL,
  codebook = NULL,
  file = "demo.xlsx",
  sheet.data = 1,
  sheet.codebook = 2,
  names = "names",
  label = "label",
  value.labels = "value.labels"
)

save_data(x, file, sep = ",", row.names = FALSE, include.codebook = TRUE)

save_text(..., file = "INFO.txt")

Arguments

x

data.frame

file

file to write to default INFO.txt

data

data.frame, default is NULL

codebook

data.frame codebook = codebook(DF), default is NULL

sheet.data, sheet.codebook

file= "demo.xlsx", sheet.data = 1, sheet.codebook = 2,

names, label, value.labels

Variablen NNamen im codebook

sep

The field separator string. In some Western European locales, Excel uses a semicolon by default, while in other locales the field separator string in Excel is a comma.

row.names, include.codebook

logical include something

...

Text

Value

data.frame

data.frame or tibble

Invisibly returns the combined data frame that is written to the csv-file.

file name

Examples

 ## Not run: 

#' require(stp25tools)
df <- data.frame(
  BMI = c(1, 2, 3, 1, 2, 3),
  WHtR = gl(2, 3, label = c("Amy", "Bob")),
  WHtR_1 = c(9, 7, 6, 8, 6, 9),
  bildprof = c(6, 7, 8, 5, 6, 7)
)

DF <-
  Label(df,
        BMI = "Body-Mass-Index",
        WHtR =  "Waist-Height-Ratio",
        WHtR_1 = "Waist-Height-Ratio")



cdb <- codebook(DF)

#' Haendisch aendern
cdb$Value.Labels[2] <- "factor: Big | Small"



## End(Not run)

 
 # Speichern des Codebook
 # save_codebook(
 #    DF,
 #   "codebook.xlsx"
 # )
 
 
 ## Not run: 
 
#' Labels und Factoren ubernehmen  
   use_codebook(
      DF, 
      file = "demo.xlsx", 
      sheet.codebook = 2
      )

#' Nur die Labels  ubernehmen  
   use_codebook(
         DF, 
         file = "demo.xlsx", 
         sheet.codebook = 2,
         value.labels = NULL
) 

#' Strucktur aus einem anderen data.frame uebernehmen
#  use_codebook(DF1, codebook(DF))

#' Daten und Strucktur im Excell-File
#  use_codebook(file = "demo.xlsx")

## End(Not run)

## Not run: 
# require(stp25tools)
dat <-  Label(
  data.frame(
  month = rep(1:3, 2),
  student = rep(c("Amy", "Bob"), each = 3),
  A = c(19, 27, 16, 28, 10, 29),
  B = c(6.45, 7.47, 8.76, 5.01, 6.91, 3.47)
  ),
  month="Monat", student="Student", A= "Anzahl", B= "B-Score" )


#' Speichern der Kompletten Strucktur
save_data(dat, "demo.xlsx")

## End(Not run)

## Not run: 
 save_text(
"Analyse der Auswirkungen des Homeoffice während der
Corona-Pandemie, insbesondere auf 
Schlafverhalten, Physis und Psyche“ Titel der Arbeit"
)

## End(Not run)

stp4/stp25tools documentation built on Feb. 27, 2025, 11:14 p.m.