aaply bug when all the values in any column are NA #169

Closed
Derek-Jones opened this Issue Jul 22, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@Derek-Jones

If all the values in any column are NA then a weird error occurs, see below.
This looks like unintended behavior, i.e., an error, to me?

If any element of a column is not NA the error does not occur.

Only tried it with aaply (which is where I found it).

t1=data.frame(a=c(1, 2, 3), b=c(NA, 1, NA))
aaply(t1, 1, function(df) return(1))
1 2 3
1 1 1

t2=data.frame(a=c(1, 2, 3), b=c(NA, NA, NA))
aaply(t2, 1, function(df) return(1))
Error in dim(out_array) <- out_dim :
dims [product 0] do not match the length of object [3]

@krlmlr

This comment has been minimized.

Show comment
Hide comment
@krlmlr

krlmlr Jul 22, 2013

Contributor

This works for me:

daply(t2, 1, function(df) return(1))
Contributor

krlmlr commented Jul 22, 2013

This works for me:

daply(t2, 1, function(df) return(1))
@Derek-Jones

This comment has been minimized.

Show comment
Hide comment
@Derek-Jones

Derek-Jones Jul 22, 2013

I'm using plyr1.8 with R 15.3. Recently installed everything on a new machine (64bit Intel, running Suse 12.3).

Also get the problem from RStudio on an AMD box running Windows XP (plyr1.8 with R 15.3)

I'm using plyr1.8 with R 15.3. Recently installed everything on a new machine (64bit Intel, running Suse 12.3).

Also get the problem from RStudio on an AMD box running Windows XP (plyr1.8 with R 15.3)

@krlmlr

This comment has been minimized.

Show comment
Hide comment
@krlmlr

krlmlr Jul 22, 2013

Contributor

I get the same error you see when calling aaply. When using daply (which is preferred, since t2 is a data frame after all), everything is fine.

Contributor

krlmlr commented Jul 22, 2013

I get the same error you see when calling aaply. When using daply (which is preferred, since t2 is a data frame after all), everything is fine.

@hadley hadley closed this in d0be1df Jan 2, 2014

wibeasley added a commit to wibeasley/plyr that referenced this issue Jan 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment