Meaning of Ddply Error: 'Names' Attribute [9] Must Be the Same Length as the Vector [1]

meaning of ddply error: 'names' attribute [9] must be the same length as the vector [1]

I fixed this problem I was having by converting format from POSIXlt to POSIXct as Hadley suggests above - one line of code:

    mydata$datetime<-strptime(mydata$datetime, "%Y-%m-%d %H:%M:%S") # original conversion from datetime string : > class(mydata$datetime) [1] "POSIXlt" "POSIXt" 
mydata$datetime<-as.POSIXct(mydata$datetime) # convert to POSIXct to use in data frames / ddply

ddply error: Error in attributes(out) - attributes(col) : 'names' attribute must be the same length as the vector

The issue was with the "names" attribute of the "Species" column:

$ Species : Factor w/ 10 levels "Arctosafulvolineata",..: 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*, "names")= chr "1" "1" "1" "1" ...

I removed them with the following code and ddply worked:

> names(uncertainty.long$Species) <- "NULL"
> ddply(uncertainty.long, .(Species), "nrow")
Species nrow
1 Arctosafulvolineata 3800
2 Argyronetaaquatica 3800
3 Dolomedesplantarius 3800
4 Enoplognathamordax 3800
5 Iciussubinermis 3800
6 Neonvalentulus 3800
7 Pardosabifasciata 3800
8 Pardosaoreophila 3800
9 Piratauliginosus 3800
10 Trochosaspinipalpis 3800


Related Topics



Leave a reply



Submit