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

Solution 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

Solution 2:

You have probably already seen this and it has not helped. I guess we probably do not have an answer yet because people cannot reproduce your error.

A dput or smaller head(dput()) might help this. But here is an alternative using base:

x <- data.frame(A=c("a","b","c","a"),B=c("e","d","d","d"))

ddply(x,.(A),summarise, Freq = length(B))
  A Freq
1 a    2
2 b    1
3 c    1

 tapply(x$B,x$A,length)
a b c 
2 1 1 

Does this tapply work for you?

x2 <- data.frame(A=c("[email protected]", "[email protected]"),
                 B=c("please help a newbie compile mplayer :-)", 
                     "re: please help a newbie compile mplayer :-)"))

tapply(x2$B,x2$A,length)
[email protected] [email protected] 
              1                   1 

ddply(x2,.(A),summarise, Freq = length(B))
                    A Freq
1  [email protected]    1
2 [email protected]    1

you could also try more simply:

table(x2$A)

 [email protected] [email protected] 
              1                   1