-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combine mrs #8
base: master
Are you sure you want to change the base?
Combine mrs #8
Conversation
…o made test for combine mrs
R/combine-arrays.R
Outdated
##' description as well as any other variables you would like to combine | ||
##' @return a new variable with combine values from the arrays | ||
##' @export | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to eliminate this space and run make doc
again. I suspect this is why you don't have an entry in your NAMESPACE file for these functions.
print(c(subvar.urls, new_subvar.url)) | ||
subvars <- subvars[match(urls(subvars),c(subvar.urls, new_subvar.url))] | ||
names(subvars) <- c(subvar.names[na.omit(match(urls(subvars), subvar.urls))], new_subvar.name) | ||
print(names(subvars)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can delete these 6 lines. The three lines below do this more robustly.
##' if false, 'not selected' will be given priority | ||
##' @return a new variable with combined responses from the given variables | ||
##' @export | ||
combineMRs <- function(var1, var2, ..., selectedFirst=TRUE){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read the tests for this correctly, the purpose of this function is to take the subvariables from two or more MR variables and make a single MR from them--is that right? If so, how about we keep the first MR, unbind the rest, and use addSubvariables to add them to the first? Like:
combineMRs <- function (variable, ...) {
newsubvars <- unlist(lapply(list(...), unbind)) ## unbind returns the URLs of the unbound variables
return(addSubvariables(variable, newsubvars))
}
addSubvariables would need to take more than just one subvar, and it would need to accept URLs, but neither are too challenging (and they're more generally useful in that function itself too). And also this way, you wouldn't need separate functions to add to categorical arrays and multiple responses--same function would work.
I haven't made tests for combineArrays but to be honest I'm not sure anyone else would ever want/need that function