Mlogit function

I have a large dataset from my own survey. It is a stated preference survey where respondents had to choose between either a bicycle or a public transport commute. I have it saved as (these are columns:

Question (there were 15 possible questions. So just repeats 1..15 for a long time
ID: the ID of the respondent, 1 ... 186.
RES: Repondents saw a random 8 of the 15 questions, values are A, B or 0. A and B for bike or public transport and 0 for questions the respondent did not see
And then all the attributes.

It is in a long format.

Now when i try to do this in R I keep getting:

TM <- mlogit.data(DFemployee, choice = "choice", shape = "long", chid.var = "ID")
Error in FUN(X[[i]], ...) :
argument must be coercible to non-negative integer

or

TM <- mlogit.data(DFemployee, choice = "choice", shape = "long", chid.var = "ID", alt.var = "Question")
Error in dfidx::dfidx(data = data, dfa$idx, drop.index = dfa$drop.index, :
the two indexes don't define unique observations

Can anyone see what I am doing wrong? Its not letting me upload pictures unfortunately

Hi, welcome to the forum.

We probably need more information and some sample data . See

FAQ Asking Questions for some general information.

For easier readability please copy your code and paste it here between
```

```

A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here between
```

```

hard to tell with out some sample data, but the error comes from dfidx::dfidx

z <- data[, c(posid1[1], posid2[1])]
if (nrow(z) != nrow(unique(z)))
stop("the two indexes don't define unique observations")