Skip to content
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

as.formula and as.data.frame + reg exp for strsplit #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/FSR.R
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ FSR <- function(Xy,

if(grepl("\\*", out$models$features[m])){

tmp <- unlist(strsplit(out$models$features[m], "\\*"))
tmp <- unlist(strsplit(out$models$features[m], "[ ]*\\*[ ]*"))
if(mean(tmp %in% out$models$features[out$models$accepted]) == 1){
out$models$formula[m] <- paste(out[["best_formula"]], "+", out$models$features[m])
}else{
Expand Down
2 changes: 1 addition & 1 deletion R/FSR_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pow <- function(X, degree){

model_matrix <- function(f, d, intercept, noisy=TRUE){

tried <- try(model.matrix(f, d, na.action = "na.omit"), silent=TRUE)
tried <- try(model.matrix(as.formula(f), d, na.action = "na.omit"), silent=TRUE)

if(inherits(tried, "try-error")){
if(noisy) cat("model.matrix() reported the following error:\n", tried, "\n\n")
Expand Down
3 changes: 1 addition & 2 deletions R/plm.R
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ predict.polyFit <- function(object,newdata)
new_data <-
getPoly(newdata, object$degree, object$maxInteractDeg)$xdata
plm.newdata <- predict(object$pca.xy, new_data)[,1:object$pcaCol]
plm.newdata <- as.data.frame(plm.newdata)
} else stop('invalid pcaLocation')
} else if (object$PCA == "RSpectra") {
if (object$pcaLocation == "front") {
Expand All @@ -571,9 +570,9 @@ predict.polyFit <- function(object,newdata)
xy.eig <- object$pca.xy
plm.newdata <-
as.matrix(new_data) %*% xy.eig$vectors[,1:object$pcaCol]
plm.newdata <- as.data.frame(plm.newdata)
}
} # end doPCA
plm.newdata <- as.data.frame(plm.newdata)

if (object$use == "lm") {
pred <- predict(object$fit, plm.newdata)
Expand Down