nvm, i figured it out.
dfm <- data.frame(x=1:10)
testfunc <- function(data="dfm")
{
dat <- eval.parent(as.symbol(data))
sum(dat$x)
}
print(testfunc())
--
View this message in context:
http://r.789695.n4.nabble.com/specify-data-frame-by-name-tp2996534p2996541.html
Sent from t
I'd like to be able to specify a data frame by name in a function call. Any
ideas how this can be done?
dfm <- data.frame(x=1:10)
testfunc <- function(data="dfm")
{
dat <- data
sum(dat$x)
}
print(testfunc())
--
View this message in context:
http://r.789695.n4.nabble.com/spec
This is an example of the type of problem, and how i'm currently using
optim() to solve it.
mydata <- runif(500,-1,1)
myfunc <- function(p,d)
{
print(p <- floor(p))
ws <- function(i,n,x) sum(x[i-n+1]:x[i])
ws1 <- c(rep(NA,p[1]-1),sapply(p[1]:NROW(d),ws,p[1],d))
ws
Are there any packages that do non-linear integer otimization? Looked at
lpSolve but i'm pretty sure it only works with linear programming and not
non-linear, tried "L-BFGS-B" optim after flooring all my params, works
somewhat but seems really inefficient. Anything else I should look at?
--
Vie
I'm trying to get the following section of code to work, I think the problem
is being caused by the assignment of data to the lm function not evaluating
to "train" in the parent environment but I can't seem to figure out how to
do this.
fitmodel <- function(trial,data)
{
wrap.lm <-
>
setClass("person",representation(name="character",age="numeric",kids="list"))
[1] "person"
> bob <- new("person")
> length(b...@name)
[1] 0
> length(b...@age)
[1] 0
> length(b...@kids)
[1] 0
> is.na(b...@kids)
logical(0)
> is.na(b...@age)
logical(0)
> is.na(b...@name)
logical(0)
> b...@kids <- l
>
setClass("person",representation(age="numeric",weight="numeric"),prototype(age=NULL,weight=NULL))
[1] "person"
> bob <- new("person",age=30)
Error in validObject(.Object) :
invalid class "person" object: invalid object for slot "weight" in class
"person": got class "NULL", should be or extend
Class("person",representation(age="numeric",weight="numeric"))
[1] "person"
> bob <- new("person",age=30)
> is.null(b...@weight)
[1] FALSE
> b...@weight
numeric(0)
> b...@weight == numeric(0)
logical(0)
How can i test to see if a s4 property is assigned?
--
View this message in context:
http:/
Thanks for your helpful response.
I have a related question, i would like to further generalize the function
by having the call arg of do.call function being referenced. Like this:
model.fun <- glm
model.opt <- list(y1~1,data=df,family="binomial")
rslt <- do.call(model.fun,model.opt)
This wo
I was wondering how i can get a list of arguments to evaluate within function
call. I'd like to be able do something like this:
#mod <- glm(y~1,data=df,family="binomial")
opt <- list(family="binomial")
mod <- glm(y~1,data=df,opt)
Any idea how this can be done properly? TIA
--
View this mes
I was hoping that there might be some way to attach significance code like
the ones from summary.lm to a dataframe. Anyone know how to do something
like that. Here is the function i'd like to add that functionality to:
add1.coef <- function(model,scope,test="F",p.value=1,order.by.p=FALSE)
{
I was wondering if there is anyway to have Add1() display the coefficient
estimates for each candidate predictor along with the F test. This is for
lm() btw.
Thanks
--
View this message in context:
http://r.789695.n4.nabble.com/Add1-w-coef-estimates-tp2279662p2279662.html
Sent from the R help
12 matches
Mail list logo