Jacobi
Jacobi

Reputation: 11

Running FactoMineR package

I have a table like this:

enter image description here

It's just a sample! We read it as follow:

a1 is present in the state fl and nc.
a2 is present in the state fl and nc and so one and so far.
I have created a table using the name of the states as columns ( fl, nc etc...)
and a1, a2 as rows.
If a1 is present in fl, we have one otherwise zero.
At the end, we come up with a table with zeros and ones.

I have used the following code to create it:

st <- levels(data$X2)[-1] # to get the names of the states
v <- as.character(unlist(data[1,][-1])) # to get the names of the states where a1 is present. Here fl and nc.
as.integer(st %in% v) # Compare st and vt and we give one if we have an element in st which is equal to an element in v

data_rs <- t(apply(data, 1, function(v) as.integer(st %in% as.character(unlist(v)))))

The problem is when I run an MCA (package factorminer) on it , I get the following error message:

Error in xj[i] : only 0's may be mixed with negative subscripts

I hope that I was clear in my explanation.

Thanks

Upvotes: 1

Views: 53

Answers (0)

Related Questions