The issue occurs in the write_hrc2() function in R/writehrc.R.
Reproducible example
corr_table <- data.frame(
niveau1 = c("Total", "Total", "Total"),
niveau2 = c("A", "A", "B"),
niveau3 = c("A1", "A2", "B1")
)
write_hrc2(
corr_table = corr_table,
file_name = tempfile(fileext = ".hrc"),
sort_table = TRUE
)
Error
Error in Ops.data.frame(corr_table, corr_table_dec_left) :
‘==’ only defined for equally-sized data frames
The same error occurs with sort_table = FALSE.
Possible cause
d is computed before the first column is removed:
d <- dim.data.frame(corr_table)
if (length(unique(as.character(corr_table[,1]))) == 1) {
corr_table <- corr_table[,-1]
}
After removing the column, d is no longer consistent with corr_table.
A possible fix:
if (length(unique(as.character(corr_table[,1]))) == 1) {
corr_table <- corr_table[,-1]
d <- dim.data.frame(corr_table)
}
The issue occurs in the
write_hrc2()function inR/writehrc.R.Reproducible example
Error
The same error occurs with
sort_table = FALSE.Possible cause
dis computed before the first column is removed:After removing the column,
dis no longer consistent withcorr_table.A possible fix: