Skip to content

Commit

Permalink
lintr, whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed May 31, 2024
1 parent fc9f564 commit d905c4b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion R/data_read.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#' factors, where imported value labels will be set as factor levels. If a
#' numeric variable has _no_ value labels or less value labels than values, it
#' is not converted to factor. In this case, value labels are preserved as
#' `"labels"` attribute. Character vectors are preserved. Use
#' `"labels"` attribute. Character vectors are preserved. Use
#' `convert_factors = FALSE` to remove the automatic conversion of numeric
#' variables to factors.
#'
Expand Down
8 changes: 4 additions & 4 deletions R/data_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ data_write <- function(data,
value_labels <- value_labels[value_labels %in% unique(i)]

# guess variable type
if (!is.character(i)) {
if (is.character(i)) {
# we need this to drop haven-specific class attributes
i <- as.character(i)
} else {
# if all values are labelled, we assume factor. Use labels as levels
if (!is.null(value_labels) && length(value_labels) == insight::n_unique(i)) {
if (is.numeric(i)) {
Expand All @@ -257,9 +260,6 @@ data_write <- function(data,
# else, fall back to numeric
i <- as.numeric(as.character(i))
}
} else {
# we need this to drop haven-specific class attributes
i <- as.character(i)
}
# add back variable label
attr(i, "label") <- variable_labels
Expand Down
2 changes: 1 addition & 1 deletion man/data_read.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d905c4b

Please sign in to comment.