[Rd] The Environment variables settings in bin/R, why do they ignore environment variables of the same name?

2015-02-26 Thread Saptarshi Guha
Hello, In installation/R/bin/R i notice 1. R_HOME_DIR is hard coded e.g. R_HOME_DIR=/usr/local/lib64/R 2. It ignores R_HOME_DIR echo "WARNING: ignoring environment value of R_HOME" 3. R_SHARE_DIR, R_INCLUDE_DIR and R_DOC_DIR are also hard coded. Is there a reason why these settings do not re

Re: [Rd] A question about multiple(?) out of order ReleaseObject

2014-03-06 Thread Saptarshi Guha
08/01/rterra_first_post.html Cheers Saptarshi On Thu, Mar 6, 2014 at 7:05 PM, Simon Urbanek wrote: > On Mar 6, 2014, at 5:32 PM, Saptarshi Guha wrote: > >> Hello, >> >> This is a question that probably reveals my lack of understanding. >> In a C function (call it cfu

[Rd] Many apologies: last post: A question about multiple(?) out of order ReleaseObject

2014-03-06 Thread Saptarshi Guha
Apologies, I am resending this because my emails seem to go in HTML form. (I haven't as yet figured gmail web interface) Hello, This is a question that probably reveals my lack of understanding. In a C function (call it cfunc), i created a SEXP, called S, and then called R_PreserveObject on S.

[Rd] Repost: (apologies for HTML post) A question about multiple(?) out of order ReleaseObject

2014-03-06 Thread Saptarshi Guha
Apologies, I am resending this because my emails seem to go in HTML form. Hello, This is a question that probably reveals my lack of understanding. In a C function (call it cfunc), i created a SEXP, called S, and then called R_PreserveObject on S. I returned the SEXP to the calling R function

Re: [Rd] A question about multiple(?) out of order ReleaseObject

2014-03-06 Thread Saptarshi Guha
hat R > can't see, then R_PreserveObject would be appropriate, but the situations > where doing that is a good idea are rare (though they do exist). > > HTH, > ~G > > > > > On Thu, Mar 6, 2014 at 2:32 PM, Saptarshi Guha > wrote: > >> Hello, >> >

[Rd] A question about multiple(?) out of order ReleaseObject

2014-03-06 Thread Saptarshi Guha
Hello, This is a question that probably reveals my lack of understanding. In a C function (call it cfunc), i created a SEXP, called S, and then called R_PreserveObject on S. I returned the SEXP to the calling R function (call it rfunc). Note, I didn't call R_ReleaseObject on S. v <- .Call("cfun

Re: [Rd] String Vector Encoding

2014-02-03 Thread Saptarshi Guha
True but I was hoping someone could point me where in the source code this happens. Cheers Saptarshi On Feb 3, 2014 3:37 AM, "Duncan Murdoch" wrote: > On 14-02-03 3:41 AM, Saptarshi Guha wrote: > >> Hello, >> >> I was reading through serialize.c and i c

[Rd] String Vector Encoding

2014-02-03 Thread Saptarshi Guha
Hello, I was reading through serialize.c and i couldn't answer something. In readItem, case CHARSXP, rules exists to adjust the read string for string encoding. Q1. I couldn't find where the encoding of the elements of the string vector are written? Is it when writeItem writes out the attribute

Re: [Rd] Accessing i'th element of a vector without using a macro

2013-05-20 Thread Saptarshi Guha
ns manual. > > Is there a reason this wouldn't work for your usecase? What exactly is it > that you want to do? > > ~G > > > > > On Mon, May 20, 2013 at 9:56 AM, Saptarshi Guha > wrote: >> >> Hello, >> >> I have a double vector, x. I can ac

[Rd] Accessing i'th element of a vector without using a macro

2013-05-20 Thread Saptarshi Guha
Hello, I have a double vector, x. I can access the i'th element as REAL(x)[i] Is there a function for this? I know i can write my own, but was seeing if one already exists. I did check Rinternals.h but didn't see one. Cheers Saptarshi __ R-devel@r-pr

[Rd] Accessing element of a vector using a function (as opposed to macro)

2013-05-20 Thread Saptarshi Guha
Hello, I have a double vector, x. I can access the i'th element as REAL(x)[i] Is there a function for this? I know i can write my own, but was seeing if one already exists. I did check Rinternals.h but didn't see one. Cheers Saptarshi [[alternative HTML version deleted]] _

[Rd] How to debug: Cons memory exhausted

2010-06-20 Thread Saptarshi Guha
Hello, I get an error when binary structures from a pipe 'Error: cons memory exhausted (limit reached?)' (but R does not crash) This is probably due to some bug in my code, but occurs after reading about 85K pairs of RAWSXP objects (each < 20 bytes). I do not have any explicit calls to malloc/ca

[Rd] Size of object in C

2010-03-18 Thread Saptarshi Guha
Hello, Is there a function(in R's C API), given a SEXP, that computes the size in bytes, i.e. a C equivalent of object.size() ? Thank you Saptarshi __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

[Rd] Shrinking a List

2010-03-10 Thread Saptarshi Guha
Hello, I create a VECSXP(call it A) with size N(~ 5000), i then proceed to fill the elements and find out I don't need to fill more than M (M<< N). Thus if i return A to the user's R code, he/she will see a list of length 5K of which N-M are NULLs. To avoid this, I create a new VECSXP B of length

Re: [Rd] org-mode (was Re: Feature Request: Multiline Comments)

2010-02-15 Thread Saptarshi Guha
nice to open an R source file with a TOC, click on an entry and start editing the function. Thanks saptarshi On Mon, Feb 15, 2010 at 1:01 AM, Erik Iverson wrote: > Martin Morgan wrote: >> >> On 02/14/2010 08:11 AM, Saptarshi Guha wrote: >> >>> >>> Hello, &

[Rd] Feature Request: Multiline Comments

2010-02-14 Thread Saptarshi Guha
Hello, Is it possible to extend the R lexer/parser to include multiline comments like /* acomment */ ? This way I can integrate emacs org-mode with my R code, so that I can have a table of contents, section folding, html-output of source etc. e.g /* * Display Code */ #+BEGIN_SRC R foo <- functio

[Rd] Benefit of treating NA and NaN differently for numerics

2009-12-31 Thread Saptarshi Guha
Hello, I notice in main/arithmetic.c, that NA and NaN are encoded differently(since every numeric NA comes from R_NaReal which is defined via ValueOfNA) . What is the benefit of treating these two differently? Why can't NA be a synonym for NaN? Thank you Saptarshi (R-2.9) ___

Re: [Rd] Problem compiling R library on FC4 ( conflicting declaration in Rinterface.h and stdint.h)

2009-12-27 Thread Saptarshi Guha
a current version of Fedora, if that is the >> Linux distribution you wish to stay with. Trying to debug compiler problems >> on a Linux distribution that itself has not been supported in a long time is >> asking for trouble. >> >> Marc Schwartz >> >> >>

[Rd] Problem compiling R library on FC4 ( conflicting declaration in Rinterface.h and stdint.h)

2009-12-26 Thread Saptarshi Guha
Hello, The package builds successfully on RHEL5 and OS X( 64 bit,32/64 respectively) but on FC4(32 bit) it fails with this error g++ -m32 -I/usr/include/R -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march

[Rd] Question R's parser : - parsing "x=\n 1"

2009-11-24 Thread Saptarshi Guha
Hello I was reading the source main/src/gram.y and had one question, how does R parse x = 1 According the grammar: prog: END_OF_INPUT{ return 0; } | '\n'{ return xxvalue(NULL,2,NULL); } | expr_or_assign '\n'

[Rd] Makevars, cc files in multiple directories

2009-10-29 Thread Saptarshi Guha
Hello, In the src folder of my R package I have a.cc b.cc f/g/x.cc my Makevars.in has all: $(SHLIB) upon installing only, a.o and b.o is build and the final dll is comprised of a.o and b.o How can I instruct $(SHLIB) to pick up its source files from all subdirectories (or maybe a subset,

Re: [Rd] Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'character' & 'getEncChar' must be called on a CHARSXP

2009-10-01 Thread Saptarshi Guha
those lists? Can you send us the code? If not, can you > put up the .RData file? Without a reproducible example this is hard to debug > ... > > Thanks, > Simon > > > On Oct 1, 2009, at 14:26 , Saptarshi Guha wrote: > >> Hello, >> I have list of 600K lists, eac

[Rd] Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'character' & 'getEncChar' must be called on a CHARSXP

2009-10-01 Thread Saptarshi Guha
Hello, I have list of 600K lists, each sublist a list of two elements, the first a character, the second a list of six named elements, some characters some numrics. LISTA (600K) (:= h) |__ List of two elements |__ Character |__ Named List of 6 elements (characters and numeri

Re: [Rd] Crash due to extreme example

2009-09-24 Thread Saptarshi Guha
Thanks. What caused problem? Regards Saptarshi On Thu, Sep 24, 2009 at 6:20 AM, Duncan Murdoch wrote: > Now fixed, in R-devel and R-patched. > > Duncan Murdoch > > On 23/09/2009 7:10 PM, Saptarshi Guha wrote: >> >> Hello, >> I was trying this bit of code (i kn

[Rd] Crash due to extreme example

2009-09-23 Thread Saptarshi Guha
nt physical address' Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace Running on Leopard, Macbook (intel, 4gb ram) R version 2.9.2 (2009-08-24) (No libraries loaded) Saptarshi Guha | saptarshi.g...@gmail.com | http://www.stat.p

Re: [Rd] Return a list from a .Call but segfaults

2009-09-20 Thread Saptarshi Guha
Apparantly , calling Rf_duplicate on the return value message2rexp solves it. Regards Saptarshi On Sun, Sep 20, 2009 at 12:04 AM, Saptarshi Guha wrote: > After some examination, this is what i found (i changed the code > somewhat, i dont modify rawdata anymore) > > load(&

Re: [Rd] Return a list from a .Call but segfaults

2009-09-19 Thread Saptarshi Guha
h of length 2 j=v[1:1] ; u=list();u=append(u,j) and j=v[1:15164] ; u=list();u=append(u,j) both work but for n> 15164 j=v[1:n] ; u=list();u=append(u,j) returns Error: protect(): protection stack overflow I have no idea why... Regards Saptarshi On Sat, Sep 19, 2009 at 10:15 PM, Saptarshi

[Rd] Return a list from a .Call but segfaults

2009-09-19 Thread Saptarshi Guha
SET_VECTOR_ELT(rval,i,KV); UNPROTECT(1); } UNPROTECT(1); return(rval); } SEXP kk_(char *d,int n){ SEXP k; REXP *rexp = new REXP(); rexp->Clear(); rexp->ParseFromArray(d,n); PROTECT(k = message2rexp(*rexp)); delete(rexp); UNPROTECT(1

Re: [Rd] Access to integer value of BUILTINSXP/SPECIALSXP

2009-09-12 Thread Saptarshi Guha
After some reading, what i really need is something to give access to PRIMNAME(obj). Setting #define R_USEINTERNALS doesn't work and i'd rather not use internals. Is the some exposed api call to get PRIMNAME? Thank you Saptarshi On Sat, Sep 12, 2009 at 2:08 PM, Saptarshi Guha wrot

[Rd] Access to integer value of BUILTINSXP/SPECIALSXP

2009-09-12 Thread Saptarshi Guha
Hello, For the BUILTINSXP and SPECIALSXP types, the R Internals page documents "An integer giving the offset into the table of primitives/.Internals. " What macro gives me the value of this integer? I guess something like this would work had R_USEINTERNALS been defined v->u.primsxp.offset (wh

Re: [Rd] Running an expression 1MN times using embedded R

2009-09-03 Thread Saptarshi Guha
Oh!Thanks much. Worked perfectly. Hadn't realized the importance of -Wall. Regards saptarshi On Thu, Sep 3, 2009 at 7:27 PM, Simon Urbanek wrote: > > On Sep 3, 2009, at 7:15 PM, Saptarshi Guha wrote: > >> Hello, >> I'm evaluating this expression >> express

[Rd] Running an expression 1MN times using embedded R

2009-09-03 Thread Saptarshi Guha
Hello, I'm evaluating this expression expression({ for(x in 1:5){ .Call('rh_status','x') }}) a million times from a program with R embedded in it. I have attached reproducible code that crashes with Program received signal SIGSEGV, Segmentation fault. 0x2b499ca40a6e in R_gc_internal (size

[Rd] Turn of -O2 during package build

2009-09-03 Thread Saptarshi Guha
Hello, I'm using a Makevars.in file and running my code through gdb. I understand i should turn of -O2, but R's makeconf overrides my settings /ln/meraki/custom/lib64/R/etc/Makeconf:112: warning: overriding commands for target `.cc.o' in Makevars.in .cc.o: g++ -g ${PKG_CXXFLAGS} ${PKG_LI

Re: [Rd] Turn of -O2 during package build

2009-09-03 Thread Saptarshi Guha
My own response: use %.o: %.cc and not the form given below. Regards S On Thu, Sep 3, 2009 at 12:59 PM, Saptarshi Guha wrote: > Hello, > I'm using a Makevars.in file and running my code through gdb. I > understand i should turn of -O2, but R's makeconf overrides my > s

[Rd] Depth of protection stack?

2009-09-02 Thread Saptarshi Guha
Hello, Is there a way, in C, to find how deep my current protection stack is(apart from keeping a count). I know the default nested size is 50,000 and because of some coding error i think i'm reaching it. Is there a way to find out the current depth reached? Thank you Saptarshi ___

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: >> >&

Re: [Rd] Basic Question regarding PROTECT

2009-08-24 Thread Saptarshi Guha
that it is still in use. >  The next time it needs some memory it may decide to free y and re-use that > space. > > Duncan Murdoch > > >> On Aug 24, 2009, at 8:18 AM, Duncan Murdoch >> wrote:r >> C >>> >>> On 8/23/2009 11:52 PM, Saptarshi Guha

[Rd] Basic Question regarding PROTECT

2009-08-23 Thread Saptarshi Guha
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 corresponding unprotect later on) since it is the object

Re: [Rd] Embed R, and provide a function to user scripts

2009-08-13 Thread Saptarshi Guha
Sorry about the clutter. The answer can be found on Writing R Extensions " 8.1.3 Registering symbols" Thank you Saptarshi Guha On Thu, Aug 13, 2009 at 10:01 PM, Saptarshi Guha wrote: > > Essentially I'd like to load the C function into  the load table > After

Re: [Rd] Embed R, and provide a function to user scripts

2009-08-13 Thread Saptarshi Guha
Essentially I'd like to load the C function into the load table After that, I can create an R function rboo=function(x) .Call("boo",x) then user script cann call rboo Hope that clarifies things. Thanks in advance Saptarshi Guha On Thu, Aug 13, 2009 at 9:07 PM, Saptarshi Guha

[Rd] Embed R, and provide a function to user scripts

2009-08-13 Thread Saptarshi Guha
me x<-1 boo(x) One way is to create a library with function boo that performs .Call to boo, but is there a way that I can do something like ainstall("rboo", boo) and calls to rboo in the language will be sent to 'boo' ? Thank you Saptarshi Saptarshi Guha

[Rd] A question on the serialization of a list vector

2009-07-15 Thread Saptarshi Guha
Hello, I've (by somewhat understanding serialize.c) understood how a vector of type numeric/char/raw/logical are serialized, assuming they have no attributes (e.g no attributes(x)=NULL). I assumed for lists, the content of the list is written first and then the names attribute. However nested list

Re: [Rd] In C, a fast way to slice a vector?

2009-05-11 Thread Saptarshi Guha
Impressive stuff. Nice to see people giving some though to this. I will explore the packages you mentioned. Thank you Saptarshi Guha On Mon, May 11, 2009 at 12:37 AM, Patrick Aboyoun wrote: > Saptarshi, > I know of two alternatives you can use to do fast extraction of conse

[Rd] In C, a fast way to slice a vector?

2009-05-10 Thread Saptarshi Guha
there a more efficient method? Regards Saptarshi Guha __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] set.seed and /dev/random

2009-05-03 Thread Saptarshi Guha
Interesting stuff. Thank you Saptarshi On Sat, May 2, 2009 at 7:21 PM, Dirk Eddelbuettel wrote: > > On 2 May 2009 at 18:53, Saptarshi Guha wrote: > | Hello, > | In ?set.seed I notice that a seed is created from the system time. > | Thus if two machines were (hypothetically)

[Rd] set.seed and /dev/random

2009-05-02 Thread Saptarshi Guha
Hello, In ?set.seed I notice that a seed is created from the system time. Thus if two machines were (hypothetically) running for the same time and R was started simultaneously on both, the would have the same seeds (correct?). I assume reading from /dev/random would be different for both of these

Re: [Rd] RJava question(class not found with rJava's vm, though found with alternate vm)

2009-04-05 Thread Saptarshi Guha
I have continued this on the stats-rosuda-devel mailing list. Saptarshi Guha On Sun, Apr 5, 2009 at 10:12 AM, Simon Urbanek wrote: > > On Apr 5, 2009, at 9:26 AM, Saptarshi Guha wrote: > > Not sure if this the right place, but I can't seem to subscribe to the >> rJava

[Rd] RJava question(class not found with rJava's vm, though found with alternate vm)

2009-04-05 Thread Saptarshi Guha
CurrentThread(jvms[i], (void**)&jenv, NULL)) { jvm=jvms[i]; break; } } i++; } if (i==vms) error("Failed to attach to any existing JVM."); }else { JNI_CreateJavaVM(&jvm, (void **)&jenv, &args); }

[Rd] Creating a VECSXP when n is unknown(using Linked list)

2009-03-31 Thread Saptarshi Guha
Hello, I need to create a VECSXP(A) each element of which is a 2-element VECSXP. Since I dont know how many elements there will be i create a linked list of 2-element VECSXP (see code at end) Once I know the number of elements, i then go ahead allocVector A and then SET_VECTOR_ELEMENT the elements

[Rd] CTRL-C during .Call causes R to quit to command line

2009-03-29 Thread Saptarshi Guha
Hello, During a .Call e.g while(TRUE){ value <-rhsqnextKVR(rdr) ## has .Call in this function if(is.null(value)) break; } if I press CTRL-C, R exits straight to the command line. Q: How can I prevent this? I should point out that my library uses JNI, so I'm not sure if that is causing i

Re: [Rd] Setting the names attribute of a list?

2009-03-29 Thread Saptarshi Guha
fuly ran it 4MM times. Have I mis-understood the 5.9.1? Thanks for your inputs. Saptarshi Guha On Sun, Mar 29, 2009 at 10:02 PM, Martin Morgan wrote: >> // kxp and usar are two SEXP's which have not been protected >> SEXP res >> PROTECT(res); >> res= allocVector(V

[Rd] Setting the names attribute of a list?

2009-03-29 Thread Saptarshi Guha
OR_ELT(names, 0, mkChar("key")); //A SET_VECTOR_ELT(names, 1, mkChar("value")); //A setAttrib(res, R_NamesSymbol,names); //A UNPROTECT(2); return(res); Saptarshi Guha __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] [R] How to preserve data across function calls in a library package

2007-07-11 Thread Saptarshi Guha
On Jul 10, 2007, at 12:33 PM, Saptarshi Guha wrote: > Hi, > Some progress: I am using > SEXP retty; > book=Calloc(1,int); > *book=10; > PROTECT(retty=R_MakeExternalPtr(book,R_NilValue,R_NilValue)); > > then UNPROTECTING and retur

Re: [Rd] [R] How to preserve data across function calls in a library package

2007-07-10 Thread Saptarshi Guha
ddress 0x0, cause 'invalid alignment'. I can't figure out why... I would appreciate any advice provided. Rgds Saptarshi On Jul 10, 2007, at 11:41 AM, Saptarshi Guha wrote: > Hi, > I am writing an R package with two functions in C++. So far >

[Rd] How to preserve data across function calls in a library package

2007-07-10 Thread Saptarshi Guha
Hi, I am writing an R package with two functions in C++. So far everything works. Now, i would like to write a third function which would use a pointer (it is a pointer to a class object) created by first function. I tried placing this pointer outside of the function defi