Re: [Rd] Basic Question regarding PROTECT

2009-08-24 Thread Duncan Murdoch
On 8/23/2009 11:52 PM, Saptarshi Guha wrote: Hello, Suppose I have the function SEXP foo(){ SEXP s; PROTECT(s=allocVector(...)) UNPROTECT(1); return(s) } y=foo() // foo is a recusrive call Q: Am i correct in understanding that one does not need to write PROTECT(y=foo()) ?(and a correspond

Re: [Rd] Basic Question regarding PROTECT

2009-08-24 Thread Sapsi
Hello Thank you for the response. So if my call is y=foo() z=malloc ( by memory allocations , do you mean via R_alloc and allocVector and malloc or just the former two) Other statements Then I need to protect y. And in my case I don't return to R since I have embedded it. Why is this the

Re: [Rd] Basic Question regarding PROTECT

2009-08-24 Thread Duncan Murdoch
On 8/24/2009 9:10 AM, Sapsi wrote: Hello Thank you for the response. So if my call is y=foo() z=malloc ( by memory allocations , do you mean via R_alloc and allocVector and malloc or just the former two) Any allocation which is managed by R's memory manager, so that includes the former two,

Re: [Rd] Basic Question regarding PROTECT

2009-08-24 Thread Saptarshi Guha
Thank you. So the reason I wouldnt need to protect y had I returned to R, is because had i had done something like h<-.Call("boo",a) where "boo" contains y=foo() the assignment "<-" to h would have a PROTECT somewhere, i.e R's assignment is doing the protection for me. Had I not returned to R, I

Re: [Rd] Basic Question regarding PROTECT

2009-08-24 Thread Duncan Murdoch
On 8/24/2009 9:33 AM, Saptarshi Guha wrote: Thank you. So the reason I wouldnt need to protect y had I returned to R, is because had i had done something like h<-.Call("boo",a) where "boo" contains y=foo() the assignment "<-" to h would have a PROTECT somewhere, i.e R's assignment is doing the

Re: [Rd] Basic Question regarding PROTECT

2009-08-24 Thread Saptarshi Guha
Oh! Yes, this is the GC at work, "root objects" and everything referenced from them. I think I'm understanding the need for PROTECT better. Thank you Saptarshi On Mon, Aug 24, 2009 at 9:39 AM, Duncan Murdoch wrote: > On 8/24/2009 9:33 AM, Saptarshi Guha wrote: >> >> Thank you. So the reason I wo

Re: [Rd] Basic Question regarding PROTECT

2009-08-24 Thread Thomas Lumley
On Mon, 24 Aug 2009, Saptarshi Guha wrote: > Thank you. So the reason I wouldnt need to protect y had I returned to > R, is because had i had done something like > > h<-.Call("boo",a) > where "boo" contains y=foo() > > the assignment "<-" to h would have a PROTECT somewhere, i.e R's > assignment

Re: [Rd] Package-level access to Rp->R_Quiet ?

2009-08-24 Thread Dirk Eddelbuettel
On 13 August 2009 at 21:53, Dirk Eddelbuettel wrote: | I would like to simulate the effect of the command-line option --quiet from | user-level scripts and startup code. From src/main/CommandLineArgs.c I learn | that Rp->R_Quiet is set, and I see how that is used in main/main.c. | | I would use

[Rd] Formulas in gam function of mgcv package

2009-08-24 Thread Corrado
Dear R-experts, I have a question on the formulas used in the gam function of the mgcv package. I am trying to understand the relationships between: y~s(x1)+s(x2)+s(x3)+s(x4) and y~s(x1,x2,x3,x4) Does the latter contain the former? what about the smoothers of all interaction terms? I hav

[Rd] CRAN and noweb

2009-08-24 Thread Terry Therneau
his is a query for suggestions on how best to setup the package for coxme. This should be ready for CRAN in about a week - I'm working out documentation details and some last test cases. The R CMD check and INSTALL processes work great on my computer. The rub is that they depend on noweb. Both

[Rd] nchar on factors

2009-08-24 Thread Stavros Macrakis
In R 2.9.1 Windows: > nchar(factor(paste('sdf',1:10))) [1] 1 1 1 1 1 1 1 1 2 1 so it appears that nchar is counting the number of characters in the numeric representation, just like: > nchar(as.numeric(factor(paste('sdf',1:10 [1] 1 1 1 1 1 1 1 1 2 1 but ?nchar says explicitly: x: ch

Re: [Rd] nchar on factors

2009-08-24 Thread Peter Dalgaard
Stavros Macrakis wrote: In R 2.9.1 Windows: nchar(factor(paste('sdf',1:10))) [1] 1 1 1 1 1 1 1 1 2 1 so it appears that nchar is counting the number of characters in the numeric representation, just like: nchar(as.numeric(factor(paste('sdf',1:10 [1] 1 1 1 1 1 1 1 1 2 1 but ?nchar sa

Re: [Rd] nchar on factors

2009-08-24 Thread Stavros Macrakis
On Mon, Aug 24, 2009 at 5:36 PM, Peter Dalgaard wrote: > > The documentation has: > > >> > The internal equivalent of the default method of as.character is performed > on x (so there is no method dispatch). If you want to operate on non-vector > objects passing them through deparse first will be r