Error in terms.formula(formula, data = data) : attempt to use zero-length variable name

Hello,

in various code I am using, i am getting this kind of error.

boxplot(ILCobas ~ AVCdensweibl + Diabetes_Mellitus, data = Frauen)
Error in terms.formula(formula, data = data) :
attempt to use zero-length variable name

I keep checking all variables, but they seem fine.

In this case, i converted a "Chr" variable like "Diabetes_Mellitus" into a factor by first labelling and then using the function as.factor().

When i open th variable, tere are the two factors listed as well as Levels:...

an example:
dataset : data
Variable numerical: VARnum
Variable dichometric (chr): A, B

Correlation of VARnum with A + B

A: 0,1
B: 0,1

first: Labelling

data$A[data$A=="0"] <- noA
data$A[data$A=="1"] <- A

data$A <- as.factor(data$A)

#again with Variable B

data$B[data$B=="0"] <- noA
data$B[data$B=="1"] <- A

data$B <- as.factor(data$B)

describedBy (VARnum ~ A + B, data=data)
running well
boxplot ( VARnum ~ A + B, data=data)
Error in terms.formula(formula, data = data) : attempt to use zero-length variable name

Hello.
Thanks for providing code , but you could take further steps to make it more convenient for other forum users to help you.

Share some representative data that will enable your code to run and show the problematic behaviour.

You might use tools such as the library datapasta, or the base function dput() to share a portion of data in code form, i.e. that can be copied from forum and pasted to R session.

Reprex Guide

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.