Bug 16284 - mapply gives error if USE.NAMES is character vector
Summary: mapply gives error if USE.NAMES is character vector
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Language (show other bugs)
Version: R-devel (trunk)
Hardware: All All
: P5 minor
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-03-27 23:03 UTC by Sergio Oller
Modified: 2015-03-27 23:04 UTC (History)
1 user (show)

See Also:


Attachments
Patch fixing the described issue (822 bytes, patch)
2015-03-27 23:03 UTC, Sergio Oller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergio Oller 2015-03-27 23:03:57 UTC
Created attachment 1762 [details]
Patch fixing the described issue

mapply has the parameter USE.NAMES that specifies whether or not the returned value should be named. According to ?mapply, USE.NAMES can be either TRUE, FALSE or a character vector with the names to be used.

When a character vector is used the following error appears:

Error in USE.NAMES && length(dots) : invalid 'x' type in 'x && y'

These lines of code can reproduce the error:

x <- c(neg=-10,pos=10)
y <- c(-20,10)
bar <- function(x,y) {x*y}
product <- mapply(bar,x, y, USE.NAMES=TRUE)
# ok, product uses names from x

product <- mapply(bar,x, y, USE.NAMES=FALSE)
# ok, product has no names

product <- mapply(bar,x,y,USE.NAMES=c("negative", "positive"))
# ko
Error in USE.NAMES && length(dots) : invalid 'x' type in 'x && y'
# I would expect names(product) equal to c("negative", "positive")


The attached patch is based on R-devel_2015-03-26_r68103.tar.gz and fixes the issue.

If there is anything else I should do to get this issue fixed feel free to contact me. 

Thank you for your time and support.

Best,

Sergio