Skip to content

Commit

Permalink
Added support for partial entries using NA
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Nov 23, 2018
1 parent 2ed460f commit 4c78e42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/education.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ education <- function(data, qualification, institution, location, years, items){
if(!missing(items)){
data <- group_by(data, !!!edu_exprs)
edu_exprs$items <- enexpr(items)
data <- summarise(data, "items" := list(!!edu_exprs$items))
data <- summarise(data, "items" := compact_list(!!edu_exprs$items))
data <- ungroup(data)
}
else{
Expand All @@ -33,7 +33,7 @@ knit_print.vitae_education <- function(x, options){
x <- dplyr::mutate(x,
"items" := map(items, ~ glue_collapse(
glue("\\item{<<.x>>}", .open = "<<", .close = ">>")
))
) %empty% "")
)
}
else{
Expand Down
8 changes: 8 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
add_class <- function(x, subclass){
`class<-`(x, union(subclass, class(x)))
}

compact_list <- function(x){
list(x[!is.na(x)])
}

`%empty%` <- function(x, y){
if(length(x) == 0) y else x
}

0 comments on commit 4c78e42

Please sign in to comment.