Why is it returning a warning when reshaping in R?

Viewed 6199

Here is my table that needs to be in wide format:

V1      V2        V3        V4
1       A0      numeric   string
1       A1         .         .
1       A2         .         .
1       A3         .         .
1       A4         .         .
1       A5         .         .
1       A6         .         .
1       A7         .         .
2       A0         .         .
2       A1         .         .
...     ...        .         .

I've been trying with something like this:

reshape(variable.name, timevar = "V2", idvar = "V1", direction = "wide")

Which has resulted in the following, which seems to be what I want:

V1   V3.A0     V4.A0    V3.A1     ...
1    Numeric   String   Numeric   ...
2    ...       ...      ...       ...

But I get a warning message:

Warning message:
In reshapeWide(data, idvar = idvar, timevar = timevar, varying = varying,  :
multiple rows match for V2 = blah: first taken

Why is this warning happening and how can I circumvent it? I don't want to just ignore it as I'll have to do the same for several data files. Thanks! Very grateful for the help.

2 Answers
Related