[R] reshape "Error in data[, timevar] : incorrect number of dimensions"
John Kane
jrkrideau at yahoo.ca
Sun Sep 28 17:51:07 CEST 2008
Try str(svy) and see what formats the seperate variables have. It may give you a clue as to what is happening.
An alternative approach is to see if the reshape package can help you.
See See http://had.co.nz/reshape for more information on the package.
--- On Sat, 9/27/08, Keith Schnakenberg <keith.schnakenberg at gmail.com> wrote:
> From: Keith Schnakenberg <keith.schnakenberg at gmail.com>
> Subject: [R] reshape "Error in data[, timevar] : incorrect number of dimensions"
> To: r-help at r-project.org
> Received: Saturday, September 27, 2008, 4:57 PM
> I have two waves of a survey given to students at various
> middle
> schools and high schools, with student id numbers for each
> student. I
> am having difficulty reshaping the file from long to wide.
>
> My code is below:
>
> library(foreign)
> svy <- read.spss("studsur4.SAV")
>
> svy.wide <- reshape(svy, timevar="WAVE",
> idvar="id", direction="wide")
>
> "id" is the student identification number, and
> "WAVE" takes values 1
> and 2. I get the following error:
>
> Error in data[, timevar] : incorrect number of dimensions
>
> I would provide reproducible code but I can't reproduce
> the error
> with any other data. I would appreciate any conjectures as
> to why
> this is happening.
>
> Thanks,
> Keith
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
More information about the R-help
mailing list