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

dunner
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.

Currently:

> 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)]
 [1] "BASSYST"   "PRESYST"   "POSTSYST"  "SYSTINI"  
 [5] "SYST5"     "SYST10"    "SYST15"    "SYST25"  
 [9] "SYST40"    "SYST60"    "SYST240"   "BASDIAST"
[13] "PREDIAST"  "POSTDIAST" "DIASTINI"  "DIAST5"  
[17] "DIAST10"   "DIAST15"   "DIAST25"   "DIAST40"  
[21] "DIAST60"   "DIAST240"  "BASPULSE"  "PREPULSE"
[25] "POSTPULSE" "INIPULSE"  "PULSE5"    "PULSE10"  
[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<-.data.frame`(`*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.

Ross