Skip to content

Commit

Permalink
still fighting travis
Browse files Browse the repository at this point in the history
  • Loading branch information
kjhealy committed Oct 9, 2019
1 parent 02f748c commit 3cb2cb3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
5 changes: 0 additions & 5 deletions .travis.yml
Expand Up @@ -2,11 +2,6 @@ language: r
cache: packages
warnings_are_errors: false

addons:
apt:
packages:
- libudunits2-dev

before_cache: Rscript -e 'remotes::install_cran("pkgdown")'
deploy:
provider: script
Expand Down
3 changes: 1 addition & 2 deletions DESCRIPTION
Expand Up @@ -22,8 +22,7 @@ Suggests:
srvyr,
tidyr,
knitr,
rmarkdown,
tools
rmarkdown
Encoding: UTF-8
LazyData: false
Roxygen: list(markdown = FALSE)
Expand Down
36 changes: 18 additions & 18 deletions vignettes/overview.Rmd
Expand Up @@ -40,23 +40,16 @@ The GSS is a complex survey. When working with it, we need to take its structure

```{r packages}
library(dplyr)
library(forcats)
library(ggplot2)
library(haven)
library(purrr)
library(tidyr)
library(survey)
library(srvyr)
library(tools)
```


### Functions

Two quick-and-dirty functions, one to help clean some labels, the other to define some custom colors.
Three quick-and-dirty functions, one to help clean some labels, the other to define some custom colors.

```{r functions}
convert_agegrp <- function(x){
Expand Down Expand Up @@ -86,6 +79,14 @@ my_colors <- function (palette = "cb")
else stop("Choose cb, rcb, or bly only.")
}
# from help(chartr)
capwords <- function(x, strict = FALSE) {
cap <- function(x) paste(toupper(substring(x, 1, 1)),
{x <- substring(x, 2); if(strict) tolower(x) else x},
sep = "", collapse = " " )
sapply(strsplit(x, split = " "), cap, USE.NAMES = !is.null(names(x)))
}
```

### Subsetting the Dataset
Expand Down Expand Up @@ -130,19 +131,18 @@ quintiles
## Recoding
gss_fam <- gss_fam %>%
modify_at(vars(), zap_missing) %>%
modify_at(wt_vars, as.numeric) %>%
modify_at(cat_vars, as_factor) %>%
modify_at(cat_vars, fct_relabel, tolower) %>% # otherwise titlecase ignores all-caps words
modify_at(cat_vars, fct_relabel, toTitleCase) %>%
purrr::modify_at(vars(), zap_missing) %>%
purrr::modify_at(wt_vars, as.numeric) %>%
purrr::modify_at(cat_vars, as_factor) %>%
purrr::modify_at(cat_vars, forcats::fct_relabel, capwords, strict = TRUE) %>%
mutate(ageq = cut(x = age, breaks = unique(qrts), include.lowest = TRUE),
ageq = fct_relabel(ageq, convert_agegrp),
ageq = forcats::fct_relabel(ageq, convert_agegrp),
agequint = cut(x = age, breaks = unique(quintiles), include.lowest = TRUE),
agequint = fct_relabel(agequint, convert_agegrp),
agequint = forcats::fct_relabel(agequint, convert_agegrp),
year_f = droplevels(factor(year)),
young = ifelse(age < 26, "Yes", "No"),
fefam = fct_recode(fefam, NULL = "IAP", NULL = "DK", NULL = "NA"),
fefam_d = fct_recode(fefam,
fefam = forcats::fct_recode(fefam, NULL = "IAP", NULL = "DK", NULL = "NA"),
fefam_d = forcats::fct_recode(fefam,
Agree = "Strongly Agree",
Disagree = "Strongly Disagree"),
fefam_n = recode(fefam_d, "Agree" = 0, "Disagree" = 1))
Expand All @@ -168,7 +168,7 @@ options(na.action="na.pass")
gss_svy <- gss_fam %>%
filter(year > 1974) %>%
drop_na(fefam_d, young) %>%
tidyr::drop_na(fefam_d, young) %>%
mutate(stratvar = interaction(year, vstrat)) %>%
as_survey_design(id = vpsu,
strata = stratvar,
Expand Down

0 comments on commit 3cb2cb3

Please sign in to comment.