Displaying 6 results from an estimated 6 matches for "tfun1".
Did you mean:
fun1
2016 Jul 27
2
Model object, when generated in a function, saves entire environment when saved
...2016 at 11:19 AM, William Dunlap <wdunlap at tibco.com> wrote:
> One way around this problem is to make a new environment whose
> parent environment is .GlobalEnv and which contains only what the
> the call to lm() requires and to compute lm() in that environment. E.g.,
>
> tfun1 <- function (subset)
> {
> junk <- 1:1e+06
> env <- new.env(parent = globalenv())
> env$subset <- subset
> with(env, lm(Sepal.Length ~ Sepal.Width, data = iris, subset = subset))
> }
> Then we get
> > saveSize(tfun1(1:4)) # see below for def...
2016 Jul 27
3
Model object, when generated in a function, saves entire environment when saved
In the below, I generate a model from an environment that isn't
.GlobalEnv with a large object that is unrelated to the model
generation. It seems to save the irrelevant object unnecessarily. In
my actual use case, I am running and saving many models in a loop that
each use a single large data.frame (that gets collapsed into a small
data.frame for estimation), so removing it isn't an
2016 Jul 27
0
Model object, when generated in a function, saves entire environment when saved
One way around this problem is to make a new environment whose
parent environment is .GlobalEnv and which contains only what the
the call to lm() requires and to compute lm() in that environment. E.g.,
tfun1 <- function (subset)
{
junk <- 1:1e+06
env <- new.env(parent = globalenv())
env$subset <- subset
with(env, lm(Sepal.Length ~ Sepal.Width, data = iris, subset = subset))
}
Then we get
> saveSize(tfun1(1:4)) # see below for def. of saveSize
[1] 910
instead of the...
2016 Jul 27
0
Model object, when generated in a function, saves entire environment when saved
...wdunlap at tibco.com>
> wrote:
>
> > One way around this problem is to make a new environment whose
> > parent environment is .GlobalEnv and which contains only what the
> > the call to lm() requires and to compute lm() in that environment.
> E.g.,
> >
> > tfun1 <- function (subset)
> > {
> > junk <- 1:1e+06
> > env <- new.env(parent = globalenv())
> > env$subset <- subset
> > with(env, lm(Sepal.Length ~ Sepal.Width, data = iris, subset =
> subset))
> > }
> > Then we get
> >...
2011 Aug 05
2
Which is more efficient?
Greetings all,
I am curious to know if either of these two sets of code is more efficient?
Example1:
## t-test ##
colA <- temp [ , j ]
colB <- temp [ , k ]
ttr <- t.test ( colA, colB, var.equal=TRUE)
tt_pvalue [ i ] <- ttr$p.value
or
Example2:
tt_pvalue [ i ] <- t.test ( temp[ , j ], temp[ , k ], var.equal=TRUE)
-------------
I have three loops, i, j, k.
One to test the all of
2020 Jan 29
2
Model object, when generated in a function, saves entire environment when saved
...; wrote:
>>
>> > One way around this problem is to make a new environment whose
>> > parent environment is .GlobalEnv and which contains only what the
>> > the call to lm() requires and to compute lm() in that environment.
>> E.g.,
>> >
>> > tfun1 <- function (subset)
>> > {
>> > junk <- 1:1e+06
>> > env <- new.env(parent = globalenv())
>> > env$subset <- subset
>> > with(env, lm(Sepal.Length ~ Sepal.Width, data = iris, subset =
>> subset))
>> > }
>>...