Skip to content
Prev 290158 / 398498 Next

avoiding expression evaluation when calling a function

Hello,


btc1 wrote
I don't know why it takes minutes, but

1. Your function doesn't use the parameter 'obj'. If the function does what
you expect it to do,
    get rid of it.
2. In the lapply, look at the values you pass for 'framvec' and 'obj'.
    Are 'rwb$prcnt.char.depth' and 'prcnt.char.depth' the same? It's at best
confusing. Have attached 
    the data.frame 'rwb'?
3. Your loop is for i in 0:10 and the lapply for i (my.i) in 1:10.
4. The loop overwrites 'rsqrd' every time through, the lapply returns a list
of all 10 vectors.

I believe this last point is where the problem is. In your function you have
an assignment

rsqrd[i] <- r2

but for i == 2 or greater, this should give an error,

Error in rsqrd[i] <- r2 : object 'rsqrd' not found

Unless you're using the double arrow assignment, '<<-'


As for not understanding lapply, it seems you do understand it, but there's
more going on with your code
that's making it work in a strange way.

Hope this helps,

Rui Barradas


--
View this message in context: http://r.789695.n4.nabble.com/avoiding-expression-evaluation-when-calling-a-function-tp4520151p4520876.html
Sent from the R help mailing list archive at Nabble.com.