[R] Calling R object from R function
frespider
frespider at hotmail.com
Wed Nov 7 16:31:22 CET 2012
Hi,
Can you please help me with this please?
What I am trying to do is call a vector from R function and used in the new
function
So I create 4 functions with these arguments
M11 <- function(TrainData,TestData,mdat,nsam) {
ls <- list()
I have few statments one of them is
vectx <- c(,1,2,3,4,5,6,6)
vectz <- c(12,34,5,6,78,9,90)
and then................
ls(vectx=vtecx,vectz=vectz)
return(ls)
}
Then I great an new function has the following arguments
get.m <- function(dat,asim,ModelFun,M){
Sim <- list()
modInd <- ModelFun(TrainData=dat,TestData=dat,mdat=dat,nsam=0.1) *# HERE IS
MY PROBLEM HOW CAN I JUST CALL vectx without fitting the ModelFun becasue as
you see in the bottom TrainData and Test are arguments used after
resampling. I dont want to use the main dat argument?*
if(M==11){
vecx <- modInd$vectx
px <- length(vecx) # ncol for X
nam <-colnames(dat[,vecx])
Asse <- matrix(NA,nrow=asim,ncol=px)
colnames(Asse) <- nam
}
for(i in 1:asim){
set.seed(i)
Samdat <- dat[sample(1:nrow(dat), nrow(dat), replace = TRUE), ]
TrSet <- Samdat[1:50,]
TeSet <- Samdat[51:75,]
}
Model<- ModelFun(TrainData=TrSet ,TestData=TeSet ,mdat=dat,nsam=i)
Y <- Model$Y
X <- Model$X
fit <- lm(Y~X)
return(fit)
}
--
View this message in context: http://r.789695.n4.nabble.com/Calling-R-object-from-R-function-tp4648714.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list