Skip to content

Commit facb26b

Browse files
committed
Check for all NA, instead of any NA
1 parent c620d1a commit facb26b

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

R/helpers.R

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ run_abimo_command_line <- function(args, tag = latest_abimo_version())
142142
output
143143
}
144144

145+
# write.dbf.abimo --------------------------------------------------------------
146+
145147
#' writes data.frame into ABIMO-dbf
146148
#'
147149
#' Saves an existing data.frame into dBase-format
@@ -156,20 +158,12 @@ run_abimo_command_line <- function(args, tag = latest_abimo_version())
156158
#' @export
157159
write.dbf.abimo <- function (df_name, new_dbf)
158160
{
159-
na_counts <- sapply(df_name, kwb.utils::nNA)
160-
is_double <- sapply(df_name, is.double)
161-
162-
may_cause_warnings <- is_double & (na_counts > 0L)
161+
all_na <- sapply(df_name, kwb.utils::nNA) == nrow(df_name)
163162

164-
if (any(may_cause_warnings)) {
163+
if (any(all_na)) {
165164
message(
166-
"foreign::write.dbf() may cause warnings due to NA values in the ",
167-
"following numeric columns: ",
168-
paste(collapse = ", ", sprintf(
169-
"\"%s\" (%d-times)",
170-
names(which(may_cause_warnings)),
171-
na_counts[may_cause_warnings]
172-
))
165+
"foreign::write.dbf() will cause warnings due to the following empty ",
166+
"columns: ", kwb.utils::stringList(names(which(all_na)), qchar = '"')
173167
)
174168
}
175169

0 commit comments

Comments
 (0)