Reshape - novel error message and fail

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Reshape - novel error message and fail

This post was updated on .
Hello all, thanks in advance for the trouble.

I can't reshape a particular large data.frame. I have used melt and reshape successfully before, alot.

I am trying to go from wide to long format.

I wish to separate The named variables below into 3 groups : SYST, DIAST and PULSE, and have them vary according to their timepoint: BAS, PRE, POST, INI ..... 240.


> dim(book)
[1] 885 205
> typeof(book)
[1] "list"
> SYST<-grep("SYST", names(book))
> DIAST<-grep("DIAST", names(book))
> PULSE<-grep("PULSE", names(book))[1:11]
> names(book)[c(SYST,DIAST,PULSE)]
 [5] "SYST5"     "SYST10"    "SYST15"    "SYST25"  
 [9] "SYST40"    "SYST60"    "SYST240"   "BASDIAST"
[17] "DIAST10"   "DIAST15"   "DIAST25"   "DIAST40"  
[29] "PULSE15"   "PULSE25"   "PULSE40"   "PULSE60"  
[33] "PULSE240"

> TIMES=c("BAS", "PRE", "INI", "POST", "5", "10", "15", "25", "40", "60", "240")

> recovery<-reshape(book, direction="long", idvar=c(names(book)[-c(SYST,DIAST,PULSE)]), varying=c(names(book)[c(SYST,DIAST,PULSE)]), times=c("BAS", "PRE", "INI", "POST", "5", "10", "15", "25", "40", "60", "240"), v.names=c("SYST", "DIAST", "PULSE"))

Error in `row.names<`(`*tmp*`, value = c("NA.BAS", "NA.BAS",  :
  duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique value when setting 'row.names': ‘NA.BAS’

I don't know what to make of this and would value anyone's help.

Thank you.