similar to: getAttr problem

Displaying 20 results from an estimated 5000 matches similar to: "getAttr problem"

2006 Mar 27
1
Safe to UNPROTECT() when object is assigned to a list?
Hi, I'm troubleshooting some native code on Windows that very occationally (and semi-randomly) crashes R. Already looked at "everything", I just want to double check that it is safe to UNPROTECT() allocated variables as soon as they are assigned to, say, a PROTECTed list. >From (R v2.3.0) Section 5.7.1 "Handling the effects of garbage collection" in "Writing R
2005 Nov 07
3
R thread safe
Dear R-dev, I would like to accelerate my R computation by using parallel OpenMP compilers (e.g from Pathscale) on a 2-processor AMD server and I would like to know whether R is a tread safe library. The main kernel of the OpenMP parallelization is a C SEXP function that performs the computational routine in parallel with: ******************* SEXP example(SEXP list, SEXP expr, SEXP rho) {
2002 Dec 12
4
sum a list of vectors
In Mathematica there is a neat feature, where you can change the head of a list from "list" to say "+" and obtain a sum of the list elements. I can't find a way to sum a list of vectors of same length or list of matrices of the same dimension and was curious if something like that exists in R. do.call("+",list) doesn't work because "+" accepts only
2009 Jan 05
1
can't get names of R_env
Hi, I'm quite knew in R, so I might not have the R specific jargon. But here is my problem, I'm trying to access and use variabels given by a function environment, more specifically the rho in do_optim in src/main/optim.c According to the documentation http://cran.r-project.org/doc/manuals/R-ints.html#The-_0027data_0027 the envsxp is defined as a tagged pairlist. "ENVSXP: Pointers
2006 Jun 22
2
.Call and data frames
Hello, I'm trying to fetch a data frame through the C API, and have no problem doing this when all columns are numbers, but when there is a column of strings I have a problem. On the C-side the function looks like: SEXP myfunc(SEXP df), and it is called with a dataframe from the R side with: .Call("myfunc", somedataframe) On the C side (actually C++ side) I use code like this:
2005 Nov 07
4
Time-measurement in milliseconds
Hi there I'm loking for a time-measurement to measure time-differences in milliseconds. On my search, I only found the following: - package "base": Sys.time() -> only second-accuracy - package "R.utils": System$currentTimeMillis() -> returns integer of milliseconds, but accuracy is only whole seconds too. At the moment I run every bit of code to measure
2012 Dec 10
1
Changing arguments inside .Call. Wise to encourage "const" on all arguments?
I'm continuing my work on finding speedups in generalized inverse calculations in some simulations. It leads me back to .C and .Call, and some questions I've never been able to answer for myself. It may be I can push some calculations to LAPACK in or C BLAS, that's why I realized again I don't understand the call by reference or value semantics of .Call Why aren't users of
2000 Jul 12
1
getAttrib() and setAttrib()
Hello: I am looking at "Writing R Extensions", subsection 3.6.4, using R 1.1.0, under NT4.0, with VC++ 6.0. Under these conditions I can use the first method given for coding the out() function, but not the second, which uses getAttrib() and setAttrib(). I hope that someone will tell me how this second method can also be made to work. Details follow, for anyone kind enough to help.
2006 Oct 15
1
Feature request: names(someEnv) same as ls(someEnv)
Hi, I would be nice if names() returned the equivalent of ls() for environments. --- a/src/main/attrib.c +++ b/src/main/attrib.c @@ -687,6 +687,8 @@ SEXP attribute_hidden do_names(SEXP call s = CAR(args); if (isVector(s) || isList(s) || isLanguage(s)) return getAttrib(s, R_NamesSymbol); + if (isEnvironment(s)) + return R_lsInternal(s, 0); return R_NilValue; }
2008 May 07
1
dlm with constant terms
Hi, I am trying to figure how to use dlm with constant terms (possibly time-dependent) added to both equations y_t = c_t + F_t\theta_t + v_t \theta_t = d_t + G_t\theta_{t-1} + w_t, in the way that S-PLUS Finmetrics does? Is there any straightforward way to transform the above to the default setup? Thanks, Tsvetan -------------------------------------------------------- NOTICE: If received in
2014 Jun 24
2
using C code to create data frame but always return as list
there is my code,  expect return value  is a data frame but R say it is list: SEXP Julia_R_MD_NA_DataFrame(jl_value_t* Var) {  SEXP ans,names,rownames;  char evalcmd[4096];  int i;  const char* dfname="DataFrameName0tmp";  jl_set_global(jl_main_module, jl_symbol(dfname), (jl_value_t*)Var);  //Get Frame cols   sprintf(evalcmd,"size(%s,2)",dfname);  jl_value_t*
2014 Apr 03
1
question regarding lang2 command in C
Hi , I am asking too many questions , sorry for that . I am creating a data frame in C itself , reading a table . The data frame calling code looks like this ====================================== *PROTECT(dfm=lang2(install("data.frame"),df));* *SEXP res = PROTECT(eval(dfm,R_GlobalEnv));* UNPROTECT(2); return res; ================================== It works fine , now the problem
2012 Nov 15
1
bug with mapply() on an S4 object
Hi, Starting with ordinary vectors, so we know what to expect: > mapply(function(x, y) {x * y}, 101:106, rep(1:3, 2)) [1] 101 204 309 104 210 318 > mapply(function(x, y) {x * y}, 101:106, 1:3) [1] 101 204 309 104 210 318 Now with an S4 object: setClass("A", representation(aa="integer")) a <- new("A", aa=101:106) > length(a)
2006 Nov 17
1
Manipulating R lists in C
Hi, I have been studying the R manual on lists but cannot seem to create a simple R list in C - I keep on getting "'dimnames' applied to non-array" whenever I attempt to assign names to the list elements: Wanted output a list structure something like [ type="Bid", price=2.0, volume=1000 ] I can get up to a list of [ "Bid2, 2.0, 1000 ] But for the life of
2009 Mar 30
1
Setting the names attribute of a list?
Hello, I have created a vector with 2 elements(see code below) I am calling this function many thousands of times (hundreds of thousands) after some time i get *** caught segfault *** address 0x5, cause 'memory not mapped' However, if i dont set the R_NamesSymbol, I do not get any such error. Am I doing this correctly? Thank you Saptarshi ==CODE=== // kxp and usar are two SEXP's
2004 Feb 11
1
.Call setAttrib(ans,R_DimSymbol,dim); Crashes.
Hi! I want to return a matrix. The code does the R interfacing. This version does it fine. SEXP ans,dim; PROTECT(ans = NEW_NUMERIC(count*2)); memcpy(NUMERIC_POINTER(ans),result,count*sizeof(double)); memcpy(&(NUMERIC_POINTER(ans)[count]),occur,count*sizeof(double)); /** PROTECT(dim=NEW_INTEGER(2)); INTEGER_POINTER(dim)[0]=2; INTEGER_POINTER(dim)[1]=count;
2014 Mar 06
1
Create dataframe in C from table and return to R
Hi , I am trying to create a dataframe in C and sebd it back to R. Can anyone point me to the part of the source code where it is doing , let me explain the problem I am having . -------------------------------------------------------------------- My simple implementation is like this SEXP formDF() { SEXP dfm ,df , dfint , dfStr,lsnm; char *ab[3] =
2019 Nov 01
4
[External] R C api for 'inherits' S3 and S4 objects
Thank you Luke. That is why I don't use Rf_inherits but INHERITS which does not allocate, provided in the email body. I cannot do similarly for S4 classes, thus asking for some API for that. On Fri, Nov 1, 2019 at 5:56 PM Tierney, Luke <luke-tierney at uiowa.edu> wrote: > > On Fri, 1 Nov 2019, Jan Gorecki wrote: > > > Dear R developers, > > > > Motivated by
2004 Jun 16
1
off topic: C/C++ codes for pseudo inverse
Hi, I am looking for C/C++ codes for computing generalized inverse of a matrix. Can anyone help me in this regard? Thanks, Mahbub.
2019 Nov 01
3
R C api for 'inherits' S3 and S4 objects
Dear R developers, Motivated by discussion about checking inheritance of S3 and S4 objects (in head matrix/array topic) I would light to shed some light on a minor gap about that matter in R C API. Currently we are able to check inheritance for S3 class objects from C in a robust way (no allocation, thread safe). This is unfortunately not possible for S4 classes. I would kindly request new