-
Notifications
You must be signed in to change notification settings - Fork 6
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
Error in dimnamesGets
when I calling grpregOverlap
function
#8
Comments
X
is a data.frame, whereas I typically pass a matrix for X
. Here's an example that I think will reproduce your problem and also show how things "work" when X
is a matrix. I'm not yet clear on what's causing this, but I think this helps focus the troubleshooting.dimnamesGets
when I calling grpregOverlap
function
Hi the problem is from the ExpandX function in the grpregOverlap R. The line dimnames. expandX <- function(X, group) {
incidence.mat <- incidenceMatrix(X, group) # group membership incidence matrix
over.mat <- Matrix(incidence.mat %*% t(incidence.mat), sparse = TRUE,
dimnames = dimnames(incidence.mat)) # overlap matrix
grp.vec <- rep(1:nrow(over.mat), times = diag(over.mat)) # group index vector
# expand X to X.latent
X.latent <- NULL
names <- NULL
## the following code will automatically remove variables not included in 'group'
for(i in 1:nrow(incidence.mat)) {
idx <- incidence.mat[i,]==1
X.latent <- cbind(X.latent, X[, idx, drop=FALSE])
names <- c(names, colnames(incidence.mat)[idx])
# colnames(X.latent) <- c(colnames(X.latent), colnames(X)[incidence.mat[i,]==1])
}
colnames(X.latent) <- paste('grp', grp.vec, '_', names, sep = "")
X.latent
} I just comment this line, here is the code: expandX <- function(X, group) {
incidence.mat <- incidenceMatrix(X, group) # group membership incidence matrix
over.mat <- Matrix(incidence.mat %*% t(incidence.mat), sparse = TRUE)
# dimnames = dimnames(incidence.mat)) # overlap matrix
grp.vec <- rep(1:nrow(over.mat), times = diag(over.mat)) # group index vector
# expand X to X.latent
X.latent <- NULL
names <- NULL
## the following code will automatically remove variables not included in 'group'
for(i in 1:nrow(incidence.mat)) {
idx <- incidence.mat[i,]==1
X.latent <- cbind(X.latent, X[, idx, drop=FALSE])
names <- c(names, colnames(incidence.mat)[idx])
# colnames(X.latent) <- c(colnames(X.latent), colnames(X)[incidence.mat[i,]==1])
}
colnames(X.latent) <- paste('grp', grp.vec, '_', names, sep = "")
X.latent
} You can try this, it may be help. Thanks |
Wow! It works! You're my Hero! By the way, does it affect for the result? |
Hi, thank great see that works! That's the main question I am asking. The Overlap matrix indicate the number of overlaps between groups, it's dimnames are composite by group differently in Incidendence matrix the dimnames are group and variables. So the dimension is not the same as in the error. For there is no problem in the results so I think it's good. I will propose a pull request to see. |
Thanks for the response and the pull request! I'm really impressed at how you get things done really fast! |
Hi! I'm trying to perform
grpregOverlap
.But, the code in below didn't work for me.
Originally posted by @dankessler in #7 (comment)
It return below error message.
Could you please check this? Thanks!
The text was updated successfully, but these errors were encountered: