Commit 3a107a58 authored by Knut Wenzig's avatar Knut Wenzig
Browse files

korrigiere rootquestion in R-code

parent 2193b0d1
......@@ -94,20 +94,34 @@
\arrayrulecolor{DIWgruen}
%\newcommand{\varsubsection}[2]{\subsection[{#1 -- #2}]{#1\color{black}\normalfont{ – #2}\color{DIWgruen}}}
\newcommand{\varsubsection}[2]{\subsection[{#1 -- #2}]{\sffamily\bfseries\color{DIWgruen}#1\color{black}\textmd{ -- #2}\color{DIWgruen}}}
%\usepackage{sectsty}
%\subsectionfont{ \color{DIWgruen}\sectionrule{0pt}{0pt}{-5pt}{0.8pt} }
%\subsectionfont{\color{DIWgruen}\sectionrule{0pt}{0pt}{-5pt}{0.8pt}}
%\subsectionfont{\color{DIWgruen}}
% - See more at: http://www.howtotex.com/packages/horizontal-rule-under-section-titles/#sthash.6KtXjmSK.dpuf
%\newcommand{\varsubsection}[2]{\subsection[{#1 -- #2}]{#1\color{black}\normalfont{ – #2}\color{DIWgruen}}}
\newcommand{\varsubsection}[2]{\subsection[{#1 -- #2}]{\sffamily\bfseries\color{DIWgruen}#1\color{black}\textmd{ -- #2}\color{DIWgruen}}}
\usepackage[nobottomtitles*]{titlesec}
\titleformat{\subsection}
{}{\thesubsection}{1em}{}[{\color{DIWgruen}\titlerule[0.4pt]}]
%\usepackage[nobottomtitles*]{titlesec}
%\titleformat{\subsection}
% {}{\thesubsection}{1em}{}[{\color{DIWgruen}\titlerule[0.4pt]}]
% http://tex.stackexchange.com/questions/84061/how-can-i-make-a-bold-horizontal-rule-under-each-section-title
\makeatletter
\renewcommand{\sectionlinesformat}[4]{%
\@tempswafalse
\ifstr{#1}{subsection}{%
\hspace*{#2}%
\raggedsection
\@hangfrom{#3}{#4}\strut{\color{DIWgruen}\hrule height 0.4pt}%
}{%
\@hangfrom{\hskip #2#3}{#4}%
}%
}
\makeatother
% vgl. scrguide Abschnitt zu \sectionlinesformat
% Titelseite
\addtokomafont{title}{\raggedright}
%\addtokomafont{author}{\raggedright\setlength{\tabcolsep}{0pt}}
......@@ -178,6 +192,12 @@ LetterSpace = -5.0]{ScalaPro-}
\newboolean{hasSchmutztitel} %Deklaration
\newboolean{SchmutztitelWithDIWSOEPLogo}
\newcounter{toconpage}
\newboolean{hasReadingaidDE}
\newboolean{hasReadingaidEN}
\newboolean{hasDescription}
\newboolean{hasTOC}
\newboolean{selectDIWnonUTF8fonts}
\newlength{\TitleWidthOnCover}
\include{covergen}
......@@ -218,7 +238,7 @@ LetterSpace = -5.0]{ScalaPro-}
\begin{textblock*}{17.5cm}(20mm,190mm)
\SPsoepline{SOEP --- The German Socio-Economic Panel study at DIW Berlin \hfill \paperyear}
\end{textblock*}
\begin{textblock*}{14.5cm}(20mm,203mm)
\begin{textblock*}{\TitleWidthOnCover}(20mm,203mm)
\SPtitle{\papertitle}
\end{textblock*}
\begin{textblock*}{18cm}(20mm,258mm)
......
......@@ -17,38 +17,64 @@ library(dortools)
# Das steuert alles
##############################
# Ordner mit codebook.csv
codebookcsvpath <- "D:/lokal/core-doku/v31/datasets/health/"
codebookcsvpath <- "D:/lokal/dokumentation_fams/datasets/bep_mig/"
# codebookcsvpath <- paste0("D:/lokal/core-doku/v31/datasets/", dtan, "/")
codebookcsvpath <- "D:/lokal/dokumentation_fams/datasets/bep_mig/"
codebookcsvpath <- "D:/lokal/dokumentation_fams/datasets/bioagel/"
codebookcsvpath <- "D:/lokal/dokumentation_fams/datasets/biosoc/"
codebookcsvpath <- "D:/lokal/dokumentation_fams/datasets/bekind/"
codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Registry_M/"
codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Registry/"
codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Weights_14/"
codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Persons_14_M/"
codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Household_14_M/"
codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Household_14/"
codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Weights_14/"
codebookcsvpath <- "D:/lokal/core-doku/v31/datasets/bepbrutto/"
codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Persons_14/"
codebookcsvpath <- "D:/lokal/isdatadoku/datasets/bioparen/"
# codebookcsvpath <- "D:/lokal/core-doku/v31/datasets/health/"
# codebookcsvpath <- "D:/lokal/dokumentation_fams/datasets/bep_mig/"
#
# # codebookcsvpath <- paste0("D:/lokal/core-doku/v31/datasets/", dtan, "/")
# codebookcsvpath <- "D:/lokal/dokumentation_fams/datasets/bep_mig/"
# codebookcsvpath <- "D:/lokal/dokumentation_fams/datasets/bioagel/"
# codebookcsvpath <- "D:/lokal/dokumentation_fams/datasets/biosoc/"
# codebookcsvpath <- "D:/lokal/dokumentation_fams/datasets/bekind/"
# codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Registry_M/"
# codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Registry/"
# codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Weights_14/"
# codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Persons_14_M/"
# codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Household_14_M/"
# codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Household_14/"
# codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Weights_14/"
# codebookcsvpath <- "D:/lokal/core-doku/v31/datasets/bepbrutto/"
# codebookcsvpath <- "D:/lokal/piaac-l-2014/Metadata/datasets/ZA5989_Persons_14/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/bioparen/"
# codebookcsvpath <- "D:/lokal/core-doku/v31/datasets/health/"
# codebookcsvpath <- "D:/lokal/core-doku/v31/datasets/behgen/"
# codebookcsvpath <- "D:/lokal/piaac-l-2015-2016/Metadaten/datasets/weight_data2/"
# codebookcsvpath <- "D:/lokal/core-doku/datasets/bfkind/"
# codebookcsvpath <- "D:/lokal/core-doku/datasets/bfpgen/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/h/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/kid/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/biobirth/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/hgen/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/pgen/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/ppfad/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/p/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/idrm/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/inno/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/bio/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/bioage/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/pbrutto/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/bioparen/"
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/cognit/"
# codebookcsvpath <- "D:/lokal/piaac-l-2015-2016/Metadata/datasets/ZA5989_Cognit/"
# codebookcsvpath <- "D:/lokal/core-doku/datasets/ppfad/"
# codebookcsvpath <- "D:/lokal/core-doku/datasets/bfhbrutto/"
# codebookcsvpath <- "D:/lokal/piaac-l-2015-2016/Metadata/datasets/ZA5989_Cognit_BETA/"
#codebookcsvpath <- paste0("D:/lokal/core-doku/datasets/hpfad/")
#codebookcsvpath <- paste0("D:/lokal/core-doku/datasets/",dataset.name ,"/")
#codebookcsvpath <- paste0("D:/lokal/core-doku/datasets/bfpgen/")
# codebookcsvpath <- "D:/lokal/isdatadoku/datasets/hbrutto/"
codebookcsvpath <- paste0("D:/lokal/isdatadoku/datasets/",dataset.name,"/")
codebookcsvpath <- "D:/lokal/core-doku/v31/datasets/health/"
codebookcsvpath <- "D:/lokal/isdatadoku/datasets/inno/"
codebookcsvpath <- "D:/lokal/core-doku/v31/datasets/behgen/"
codebookcsvpath <- "D:/lokal/core-doku/datasets/biol/"
distribution <- "v31.1"
language <- "en"
allow.markdown <- TRUE
distribution <- "v32"
language <- "de"
allow.markdown <- FALSE
collapse.variable.groups <- TRUE
calc.abs.frequencies <- TRUE # TRUE: show only all value labels without frequencies
omit.unlabeled.values <- TRUE # if only_labeled_vals==1
optimize.tables <- TRUE
restrict.questions <- FALSE # Anzeige der Fragen begrenzen (unique Fragen im letzten Jahr)
display.question.id <- FALSE
display.question.id <- TRUE
do.xelatex <- TRUE # LaTeX-Lauf starten
rename.pdf <- TRUE # pdf>questionnaire umbenennen do.xelatex=T
......@@ -66,10 +92,18 @@ toc.on.page <- -1 # -1 wählt gute defaults, z.B. 2 bei SOEP Surv
datapath <- "D:/lokal/min_wage/datasets/Bus2015_Mindestlohn/"
datapath <- "D:/lokal/dortest/t1/datasets/auto/"
datapath <- "//hume/soep-data/DATA/soep31_de/stata/"
datapath <- "S:/MA/kwenzig/piaac_l/"
datapath <- paste0("//hume/soep-data/DATA2/SOEP-IS/SOEP-IS 2014 Generierung HiWi/Data/finaldata/",
datapath <- "//hume/soep-data/MA/kwenzig/piaac_l/"
datapath <- "//hume/abt/abt-sop/MA/jnapieraj/"
datapath <- "//hume/rdc-gen/generations/soep-core/soep.v32/pre/"
datapath <- "//hume/soep-data/MA/jnapieraj/Kind/2015/old/"
datapath <- "//hume/soep-data/DATA2/SOEP-IS/SOEP-IS 2014 Generierung HiWi/Data/finaldata/EN/"
datapath <- paste0("//hume/soep-data/DATA2/SOEP-IS/SOEP-IS_2014.1_release/download/soep-is.2014.1_stata_",
language,"/")
datapath <- "//hume/abt/abt-sop/MA/jnapieraj/piaac/"
datapath <- "//hume/soep-data/DATA/soep32_en/stata/"
datapath <- paste0("//hume/soep-data/DATA2/SOEP-IS/SOEP-IS 2015 Generierung HiWi/Data/finaldata/",
toupper(language), "/")
datapath <- "//hume/soep-data/DATA/soep31_en/stata/"
datapath <- "//hume/soep-data/DATA/soep32_de_l/stata/"
# Ordner des repositories (enthaelt Ordner LaTex und R)
path <- "D:/lokal/codebooker/"
......@@ -235,13 +269,13 @@ if(length(cplusvars)>0){
# - Wertelabel und Häufigkeiten (englisch, variabele_categories.csv)
# - question/item (logical_variables.csv)
variables.csv <- multiCSVopen(type="variables",
path=variables.csv.path, root="")
path=variables.csv.path, root="", standardize = TRUE)
variable_categories.csv <- multiCSVopen(type="variable_categories",
path=codebookcsvpath, root="")
logical_variables.csv <- multiCSVopen(type="logical_variables",
path=log_vars.csv.path, root="")
path=log_vars.csv.path, root="", standardize = TRUE)
# aus questionnaires.csv wird period zur Auswahl der Fragen benötigt
questionnaires.csv <- read.csv(paste0(meta.path, "questionnaires.csv"),
......@@ -277,7 +311,7 @@ names(gen.path) <- GetColumns("generations")
# Schritt 2: generations unten ran
generations.csv <- multiCSVopen(type="generations",
path=generations.csv.path, root="")
path=generations.csv.path, root="", standardize = TRUE)
# nur vollständig gefüllte generations-Zeilen weiterverarbeiten
if(nrow(generations.csv)>0) {
generations.csv <- generations.csv[rowSums(as.data.frame(generations.csv==""))==0, ]
......@@ -329,7 +363,7 @@ quest2var <- merge(quest2var, logical_variables.csv[, c("study", "dataset", "va
quest2var <- quest2var[quest2var$questionnaire!="", ]
questions.csv <- multiCSVopen(type="questions",
path=questions.csv.path, root="")
path=questions.csv.path, root="", standardize = TRUE)
if(nrow(questions.csv)>0) {
questions.csv$sort <- 1:nrow(questions.csv)
......@@ -337,21 +371,25 @@ if(nrow(questions.csv)>0) {
questions.csv$sort <- logical(0)
}
# rootquestions zum ranmergen aufbereiten und umbenennen
rootquestion <- questions.csv[questions.csv$item=="", c("study", "questionnaire", "question", "text", "text_de")]
names(rootquestion)[which(names(rootquestion)=="text")] <- "roottext"
names(rootquestion)[which(names(rootquestion)=="text_de")] <- "roottext_de"
quest2var <- merge(quest2var, rootquestion,
by=c("study", "questionnaire", "question"))
rootquestion <- NULL
# rootquestions ermitteln
# Inhalt von text/text_de in erster Zeile von question in questions.csv
rlequestion <- rle(as.character(questions.csv$question))
questions.csv$counter <- sequence(rlequestion$lengths)
questions.csv$roottext_de <- rep(questions.csv$text_de[questions.csv$counter==1],rlequestion$lengths)
questions.csv$roottext <- rep(questions.csv$text [questions.csv$counter==1],rlequestion$lengths)
questions.csv$text_de[questions.csv$counter==1] <- ""
questions.csv$text [questions.csv$counter==1] <- ""
questions.csv$counter <- rlequestion <- NULL
# variablenfrage ranmergen, falls gleich rootquestion: leeren
quest2var <- merge(quest2var,
questions.csv[ ,c("study", "questionnaire", "question",
"item", "text", "text_de", "concept", "sort")],
by=c("study", "questionnaire", "question", "item"),
"item", "roottext", "roottext_de", "text",
"text_de", "concept", "template.id", "sort")],
by.x=c("input_study", "questionnaire", "question", "item"),
by.y=c("study", "questionnaire", "question", "item"),
all.x=TRUE)
quest2var$text[quest2var$roottext_de==quest2var$text_de] <- ""
quest2var$text_de[quest2var$roottext_de==quest2var$text_de] <- ""
# duplikate rausschmeißen
quest2var <- quest2var[!duplicated(quest2var[,c("study", "dataset", "version",
......@@ -455,7 +493,7 @@ VarQuestionsLaTeX <- function(variable) {
"variable", "roottext",
"roottext_de", "text", "text_de",
"input_study", "questionnaire",
"question", "item", "concept", "sort")],
"question", "item", "concept", "template.id", "sort")],
by=c("study", "dataset", "version", "variable"),
all=FALSE)
if(nrow(q.tab)>0) {
......@@ -484,7 +522,8 @@ VarQuestionsLaTeX <- function(variable) {
TeXifyStr(q.tab$input_study), "/\\allowbreak ",
TeXifyStr(q.tab$questionnaire), "/\\allowbreak ",
TeXifyStr(q.tab$question), q.tab$itemdelim,
TeXifyStr(q.tab$item), ")}\n", collapse="\n")
TeXifyStr(q.tab$item), "\\allowbreak[",
TeXifyStr(q.tab$template.id), "])}\n", collapse="\n")
} else {
vq.latex <- paste0("\\fnr{?} ", TeXifyStr(q.tab$roottext),
q.tab$textdelim, TeXifyStr(q.tab$text), "\n", collapse="\n")
......@@ -740,7 +779,8 @@ if(collapse.variable.groups) {
titles.csv <- read.csv(paste0(addpath, "titles.csv"),
colClasses="character",encoding="UTF-8")
title.row <- which((titles.csv$study==study & titles.csv$distribution==distribution &
titles.csv$dataset==dataset.name & titles.csv$version==version) ==
titles.csv$dataset==dataset.name & titles.csv$version==version &
titles.csv$language==language) ==
TRUE)
titles.csv <- titles.csv[title.row,][1,]
if(row.names(titles.csv)[1]=="NA"){
......@@ -754,6 +794,8 @@ year <- TeXifyStr(titles.csv$Erscheinungsjahr)
author <- titles.csv$Autor
doi <- titles.csv$zuDOI
dataset.group <- titles.csv$dataset.group
cover.width <- titles.csv$cover.width
if(cover.width=="") cover.width <- "15.5cm"
if(nchar(doi)>0){
if(dataset.group!=""){
the.this.file.s <- paste0("The files ", TeXifyStr(dataset.group), " are")
......@@ -761,7 +803,7 @@ if(nchar(doi)>0){
the.this.file.s <- paste0("The file ", TeXifyStr(dataset.name), " is")
}
dataset.footnote <- paste0(the.this.file.s,
" part of a collection, which is released with \\hyperref{http://dx.doi.org/",
" part of a collection, which is released with \\hyperref{http://doi.org/",
doi, "}{}{}{doi:", TeXifyStr(doi), "}.")
} else {
dataset.footnote <- ""
......@@ -792,7 +834,7 @@ cover.infos <- CoverLaTeX(language=language,
is.surveypaper = is.surveypaper, series = series, paperno=paperno,
has.schmutztitel=has.schmutztitel,
schmutztitel.has.DIWSOEPLogo = schmutztitel.has.DIWSOEPLogo,
toc.on.page = toc.on.page)
toc.on.page = toc.on.page, cover.width = cover.width)
cat(cover.infos,
file=(con <- file(covertexfile, "w", encoding = "UTF-8")),
......@@ -806,11 +848,6 @@ cat(DatasetLaTeX(codebook.csv),
close(con)
if(do.xelatex){
if(is.surveypaper | has.schmutztitel){
tex.file.name <- "spp_codebook"
} else {
tex.file.name <- "codebook"
}
if(is.surveypaper){
rename.to.filename <- paste0("diw_ssp", substr("0000", 1, 4-nchar(paperno)),
paperno, ".pdf")
......@@ -822,12 +859,12 @@ if(do.xelatex){
xelatexcmd <- paste0("xelatex --aux-directory=", xelatexpath,
" --include-directory=", xelatexpath,
" --output-directory=", xelatexpath,
" ", xelatexpath, tex.file.name, ".tex")
" ", xelatexpath, "spp_codebook.tex")
log <- shell(xelatexcmd, invisible=FALSE, intern=TRUE)
log <- shell(xelatexcmd, invisible=FALSE, intern=TRUE)
log <- shell(xelatexcmd, invisible=FALSE, intern=TRUE)
if(rename.pdf){
file.copy(from=paste0(xelatexpath, tex.file.name, ".pdf"),
file.copy(from=paste0(xelatexpath, "spp_codebook.pdf"),
to=paste0(xelatexpath, rename.to.filename),
overwrite = TRUE, recursive = FALSE,
copy.mode = FALSE, copy.date = TRUE)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment