Skip to content

Commit

Permalink
Handle POR files with empty variable labels
Browse files Browse the repository at this point in the history
  • Loading branch information
melff committed Jul 10, 2018
1 parent 100ffc0 commit 297f331
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/R/spss-portable-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ spss.portable.file <- function(
variables[types>0] <- list(new("character.item"))
names(variables) <- names(types)

varlabs <- sapply(data.spec$dictionary,"[[",i="label")
varlabs <- varlabs[nzchar(varlabs)]
varlabs <- lapply(data.spec$dictionary,"[[",i="label")
varlabs <- unlist(varlabs)
if(length(varlabs))
varlabs <- varlabs[nzchar(varlabs)]

vallabs <- data.spec$value.labels
vallabs.vars <- lapply(vallabs,"[[",i="vars")
Expand All @@ -43,7 +45,7 @@ spss.portable.file <- function(
message("using ",missval.file)
missings <- spss.parse.missing.values(missval.file)
}

if(length(varlabs))
variables[names(varlabs)] <- mapply("description<-",variables[names(varlabs)],varlabs)
if(length(vallabs))
Expand Down

0 comments on commit 297f331

Please sign in to comment.