[R] Reshape - novel error message and fail
dunner
ross.dunne at tcd.ie
Wed Sep 14 19:02:04 CEST 2011
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
--
View this message in context: http://r.789695.n4.nabble.com/Reshape-novel-error-message-and-fail-tp3813533p3813533.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list