Re: [Rd] memory allocation if multiple names point to the same object

2014-06-03 Thread Michael Lawrence
This is because R keeps track of the names of an object, until there are 2 names. Thus, once it reaches 2, it can no longer decrement the named count. In this example, 'a' reaches 2 names ('a' and 'b'), thus R does not know that 'a' only has one name at the end. Luke has added reference counting t

[Rd] setting environmental variable inside R function to call C function

2014-06-03 Thread Bowen Meng
wrapper <- function(){ Sys.setenv(TMP="A") print(Sys.getenv("TMP")) .C("c_fun") } As the example above, I hope to set an env var $TMP inside the R function "wrapper", which affects the functionality of the C function call "c_fun". Also the print line shows that $TMP is set to be "A", but t

Re: [Rd] setting environmental variable inside R function to call C function

2014-06-03 Thread Barry Rowlingson
What does c_fun look like? Here's mine: #include #include void c_fun(){ printf("TMP is %s\n", getenv("TMP")); } and I then do this at the shell prompt: R CMD SHLIB c_fun.c and this at the R prompt: dyn.load("c_fun.so") wrapper() and I get: > wrapper() [1] "A" TMP is A list() Is that

Re: [Rd] setting environmental variable inside R function to call C function

2014-06-03 Thread Dirk Eddelbuettel
I suspect the intend is to send a value from R to compiled code. Which happens to be a problem for which Rcpp offers a pretty convenient solution. And if you really, really want to, you can even program in C inside of an Rcpp interface: R> cppFunction("int foo(std::string txt) { Rprintf(\"Var

Re: [Rd] A bug in princomp(), perhaps?

2014-06-03 Thread Ravi Varadhan
Thank you, Ben. Best, Ravi -Original Message- From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On Behalf Of Ben Bolker Sent: Monday, June 02, 2014 8:07 PM To: r-de...@stat.math.ethz.ch Subject: Re: [Rd] A bug in princomp(), perhaps? Ben Bolker gmail.com> wri

Re: [Rd] A bug in princomp(), perhaps?

2014-06-03 Thread Ravi Varadhan
Perhaps, adding Gavin's work around for a dataframe with missing values might also be useful to the documentation: princomp(na.omit(x)) Thanks, Ravi -Original Message- From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On Behalf Of Ben Bolker Sent: Monday, June

[Rd] cuda-memcheck to debug CUDA-enabled R packages

2014-06-03 Thread landau
I'm building a simple R extension around a CUDA-enabled dynamic library, and I want to run the whole package with cuda-memcheck for debugging purposes. I can run it just fine with Valgrind: $ R --no-save -d valgrind < test.R However, if I try the same thing with cuda-memcheck, $ R --no-save -d c

Re: [Rd] memory allocation if multiple names point to the same object

2014-06-03 Thread Dénes Tóth
Dear Michael, thank you for the enlightenment. Just for the records, here is the solution that Michael referred to: http://developer.r-project.org/Refcnt.html Best, Denes On 06/03/2014 03:57 PM, Michael Lawrence wrote: This is because R keeps track of the names of an object, until there