You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried converting Demographic.E4 allele to a factor with 2 levels (as opposed to a character variable) and I still was getting the same error. Please note, there are no NA’s in this variable:
summary(ImputesAmyloid$Demographic.E4 allele)
No Yes
173 51
I then tried to recreate the error using the states dataset from R and I couldn’t. I used this code and it ran fine:
states = as.data.frame(state.x77)
states$murdercat = states$Murder
states$murdercat= as.factor(ifelse(states$Murder <= 5, "Low",
ifelse(states$Murder > 5, "High", NA)))
test = moderation1(y = "Income",
x = "Illiteracy",
m = "murdercat",
cvs = "Frost",
df = states,
with_out = T)
I so I created a new ‘categorical’ variable in my dataset (even though Demographic.E4 allele was already categorical):
ImputesAmyloid$allelecat = ImputesAmyloid$Demographic.E4 allele
ImputesAmyloid$allelecat = as.factor(ifelse(ImputesAmyloid$Demographic.E4 allele == "No", "No",
ifelse(ImputesAmyloid$Demographic.E4 allele == "Yes", "Yes", NA)))
Then ran the model using the new variable and it ran fine.
From Kelsey Sewell:
Update:
I tried converting
Demographic.E4 allele
to a factor with 2 levels (as opposed to a character variable) and I still was getting the same error. Please note, there are no NA’s in this variable:summary(ImputesAmyloid$
Demographic.E4 allele
)No Yes
173 51
I then tried to recreate the error using the states dataset from R and I couldn’t. I used this code and it ran fine:
states = as.data.frame(state.x77)
states$murdercat = states$Murder
states$murdercat= as.factor(ifelse(states$Murder <= 5, "Low",
ifelse(states$Murder > 5, "High", NA)))
test = moderation1(y = "Income",
x = "Illiteracy",
m = "murdercat",
cvs = "Frost",
df = states,
with_out = T)
I so I created a new ‘categorical’ variable in my dataset (even though
Demographic.E4 allele
was already categorical):ImputesAmyloid$allelecat = ImputesAmyloid$
Demographic.E4 allele
ImputesAmyloid$allelecat = as.factor(ifelse(ImputesAmyloid$
Demographic.E4 allele
== "No", "No",ifelse(ImputesAmyloid$
Demographic.E4 allele
== "Yes", "Yes", NA)))Then ran the model using the new variable and it ran fine.
I really have no idea why this worked as
Demographic.E4 allele
andallelecat
appear to be exactly the same?The only difference I can think of is that
Demographic.E4 allele
was read in from excel using the readxl package, whereasallelecat
wasn’t.The text was updated successfully, but these errors were encountered: