Displaying 20 results from an estimated 51 matches for "langsxp".
2024 Jul 06
1
API for converting LANGSXP to LISTSXP?
On Fri, 5 Jul 2024 15:27:50 +0800
Kevin Ushey <kevinushey at gmail.com> wrote:
> A common idiom in the R sources is to convert objects between LANGSXP
> and LISTSXP by using SET_TYPEOF. However, this is soon going to be
> disallowed in packages.
Would you mind providing an example where a package needs to take an
existing LISTSXP and convert it to a LANGSXP (or vice versa)? I think
that Luke Tierney intended to replace the uses of
SET_TYPE...
2004 Jul 06
1
Wrong object type produced - LANGSXP should be LISTSXP (PR#7055)
Full_Name: David Bauer
Version: 1.9
OS: Linux
Submission from: (NULL) (160.91.245.8)
In the file gram.y, the xxsubscript function generates a LANGSXP with another
LANGSXP as its CDR. I believe that this is a mistake and that the second
LANGSXP should be a LISTSXP. The inputs a1, a3 are parameters to the subscript
function (a2), and as such they should be in a dotted-pair list.
David Bauer
--- gram.y.orig 2003-11-15 05:40:35.000000000 -...
2024 Jul 05
2
API for converting LANGSXP to LISTSXP?
Hi,
A common idiom in the R sources is to convert objects between LANGSXP
and LISTSXP by using SET_TYPEOF. However, this is soon going to be
disallowed in packages. From what I can see, there isn't currently a
direct way to convert between these two object types using the
available API. At the R level, one can convert calls to pairlists
with:
> as.call(pairlist(a...
2003 Dec 16
1
Memory issues in "aggregate" (PR#5829)
...; colnames(pseudo.hist) <- c("Delta", "N")
> detach(profiles)
> gc()
used (Mb) gc trigger (Mb)
Ncells 701188 18.8 2683553 71.7
Vcells 1447712 11.1 8201413 62.6
> memory.profile()
NILSXP SYMSXP LISTSXP CLOSXP ENVSXP PROMSXP LANGSXP
1 7228 244243 3949 495 773 113819
SPECIALSXP BUILTINSXP CHARSXP LGLSXP INTSXP
207 1177 283663 4661 0 0 49
REALSXP CPLXSXP STRSXP DOTSXP ANYSXP VECSX...
1997 Dec 12
3
R-beta: R-0.60.1 on hpux10.2
Hello R-helpers,
I tried to do "make test" , and it is failing:
data()
Error: stack overflow
?data
Error: Stack overflow
data(rivers)
Error: incorrect tag type
R also initially it balked at:
apropos("\\\\[")
So, I skipped it :-)
This stuff is working on R-0.50-a4 that I have.
Anyone built R-0.60.1 on hpux??
Best regards,
Osman
2006 Jun 03
3
More on bug 7924
...78,
env = 0x508818}, promsxp = {value = 0xa2b488, expr = 0x9e8d78,
env = 0x508818}}}
So I think this does confirm that the call to identical does indeed
change the top level objects named from 1 to 2.
I still need to learn more about how objects are made and what an
object of LANGSXP type really is and what the proper setting is for
named for an object that is a list of other objects whose named
values are set to 0, 1, or 2 respectively.
My guess is just before a final objects is assigned, we might have to
walk the tree of subobjects in some way to make sure all of the...
2001 Dec 07
2
Memory problem
Dear all,
I have written a little R program to convert images. See below. Within the
loop over j (the filenames) memory consumption grows constantly. rm( ... )
inside the loop did not help. Memory does not grow if I remove the writeBin
statements between the two #-------- marks. But obviously this is not
solution I want...
Thanks for any advice.
Manfred Baumstark
P.S. As I'm new to R:
2002 Oct 14
1
R 1.6.0 Solaris crash with xmalloc: out of virtual memory
...year 2002
month 10
day 01
language R
----------------- At the beginning -------------
--- gc() returns:
used (Mb) gc trigger (Mb)
Ncells 254150 6.8 467875 12.5
Vcells 408499 3.2 886807 6.8
--- memory.profile() returns:
NilSXP SymSXP ListSXP CloSXP EnvSXP PromSXP LangSXP SpecialSXP
1 4919 128880 1440 13 18 63607 59
BUILTINSXP CHARSXP LGLSXP - - INTSXP REALSXP CPLXSXP STRSXP
513 37178 1712 0 0 237 9047 8 10201
DOTSXP ANYSXP VECSXP EXPRSXP - EXTPTRSXP WEAKREFSXP
1 0 341 2 0 0...
2009 Jan 08
1
Callbacks seems to get GCed.
...Def cMethods[] = {
{NULL}
};
R_CallMethodDef callMethods[] = {
{"set_callback1", (DL_FUNC) &set_callback1, 1},
{"set_callback2", (DL_FUNC) &set_callback2, 1},
{NULL}
};
void r_trigger_callback1()
{
int errorOccurred;
SEXP f = NULL;
f = allocVector(LANGSXP, 1);
SETCAR(f, callback1);
PROTECT(f);
R_tryEval(f, R_GlobalEnv, &errorOccurred);
UNPROTECT(1);
}
void r_trigger_callback2()
{
int errorOccurred;
SEXP f = NULL;
f = allocVector(LANGSXP, 1);
SETCAR(f, callback2);
PROTECT(f);
R_tryEval(f, R_GlobalEnv, &errorOcc...
2009 Mar 03
1
profiler and loops
...ere are a few thoughts:
in the function "doprof" in eval.c, this loop write the call stack on
the profiler file:
for (cptr = R_GlobalContext; cptr; cptr = cptr->nextcontext) {
if ((cptr->callflag & (CTXT_FUNCTION | CTXT_BUILTIN))
&& TYPEOF(cptr->call) == LANGSXP) {
SEXP fun = CAR(cptr->call);
if (!newline) newline = 1;
fprintf(R_ProfileOutfile, "\"%s\" ",
TYPEOF(fun) == SYMSXP ? CHAR(PRINTNAME(fun)) :
"<Anonymous>");
}
}
so we can see it only cares about context CTXT_...
2020 Sep 06
8
some questions about R internal SEXP types
...said to hold "usually"
LISTSXP or NULL. What does the "usually" mean here? Is it possible
for the CDR to hold values other than LISTSXP or NULL, and is
this?NULL NILSXP or C NULL? I assume that the CAR can hold any type
of?SEXP, is this correct?
2. The LANGSXP and DOTSXP types are lists, but the R-ints comments on
them do not say whether the CDR of one of these lists is the same at
the head of the list of devolves to a LISTSXP. Looking through the
code suggests to me that functions that allocate these two types
allocate a LISTSXP...
2010 Sep 09
0
calling Rf_initEmbeddedR error
...ackage load
SEXP e = R_NilValue;
SEXP r = R_NilValue;
PROTECT(e = lang2(install("source"), mkString("hreg.r")));
r = R_tryEval(e, R_GlobalEnv, NULL); // -----> success
UNPROTECT(1);
// Function load
SEXP fun;
PROTECT(e = allocVector(LANGSXP, 3));
fun = findFun(install("hreg"), R_GlobalEnv);
if(fun == R_NilValue) // -----> success
{
UNPROTECT(1);
throw std::range_error("R Function not found");
}
SETCAR(e, fun);
UNPROTECT(1);
// End R...
2008 Mar 29
0
"Writing R Extensions": bad example with CAR / CDR as lvalues (PR#11054)
...This is a rather minor "documentation bug", certainly not at all urgent.
The manual "Writing R extensions" explains in section 5.10 ("Evaluating R
expressions from C") how to use the eval function. Without going into much
details, an example is given how to build up a LANGSXP pairlist to represent an
expression.
This example is taken at verbatim from src/main/print.c, and uses CAR and CDR as
l-values, e.g.
CAR(t) = install("print")
This has just confused me quite a bit, as my own code, which I wrote following
this example, did not compile, complaining abo...
2010 May 14
1
The parsing of '{' and a function that equal to '{'
Hello All,
I tried the sample code from the help. Although '{' is assigned to
'do', the call syntaxes for 'do' and '{' are not the same ('do' has
','s, but '{' has line breaks). I guess there is a difference in
parsing the code block of 'do' and the code block of '{'. Could you
please let me know some internal details so that
2008 Mar 31
1
(PR#11054) "Writing R Extensions": bad example with CAR /
...nor "documentation bug", certainly not at all urgent.
>
> The manual "Writing R extensions" explains in section 5.10 ("Evaluating R
> expressions from C") how to use the eval function. Without going into much
> details, an example is given how to build up a LANGSXP pairlist to represent an
> expression.
>
> This example is taken at verbatim from src/main/print.c, and uses CAR and CDR as
> l-values, e.g.
> CAR(t) = install("print")
>
> This has just confused me quite a bit, as my own code, which I wrote following
> this exam...
2009 Sep 29
3
How do I access class slots from C?
Hi
I'm trying to implement something similar to the following R snippet using
C. I seem to have hit the wall on accessing class slots using C.
library(fPortfolio)
lppData <- 100 * LPP2005.RET[, 1:6]
ewSpec <- portfolioSpec()
nAssets <- ncol(lppData)
setWeights(ewSpec) <- rep(1/nAssets, times = nAssets)
ewPortfolio <- feasiblePortfolio(
data = lppData,
spec = ewSpec,
2016 May 20
2
identical on closures
...unctions contain different environments, AFAICT.
Environments are compared only by exact pointer, so this forces return
FALSE.
Snippets from .Internal(inspect(x)) and .Internal(inspect(y)):
@cca008 03 CLOSXP g0c0 [MARK,NAM(2),ATT]
FORMALS:
@604b58 00 NILSXP g0c0 [MARK,NAM(2)]
BODY:
@cc9650 06 LANGSXP g0c0 [MARK,ATT]
@604998 01 SYMSXP g0c0 [MARK,LCK,gp=0x5000] "{" (has value)
ATTRIB:
@cc9570 02 LISTSXP g0c0 [MARK]
TAG: @60dd70 01 SYMSXP g0c0 [MARK,LCK,gp=0x4000] "srcref" (has value)
@15a65d8 19 VECSXP g0c1 [MARK] (len=1, tl=0)
@10f3dd0 13 INTSXP g0c3...
2016 May 20
2
identical on closures
I'm confused by this:
> identical(function() {}, function() {})
[1] FALSE
Yet, after loading the Matrix package (which redefines det), the
following is checked (in library.checkConflicts):
> identical(get("det", baseenv()), get("det", asNamespace("Matrix")),
ignore.environment=T)
[1] TRUE
I've looked at the code in identical.c and for closures it
2020 Feb 26
1
Profiling: attributing costs to place of invocation (instead of place of evaluation)?
...or (cptr = R_GlobalContext; cptr; cptr = cptr->nextcontext) {
+??? if (sysparent != NULL && cptr->cloenv != sysparent &&
cptr->sysparent != sysparent) continue;
???? if ((cptr->callflag & (CTXT_FUNCTION | CTXT_BUILTIN))
???? ??? && TYPEOF(cptr->call) == LANGSXP) {
???? ??? SEXP fun = CAR(cptr->call);
@@ -292,6 +295,8 @@
???? ??? ??? else
???? ??? ??? lineprof(buf, cptr->srcref);
???? ??? }
+
+??? ??? sysparent = cptr->sysparent;
???? ??? }
???? }
???? }
2005 Jan 03
2
Memory problem ... Again
...gc()
used (Mb) gc trigger (Mb)
Ncells 797971 21.4 1710298 45.7
Vcells 76716794 585.4 305954055 2334.3
...
> mem.limits()
nsize vsize
NA NA
> object.size(Data)
[1] 608355664
> memory.profile()
NILSXP SYMSXP LISTSXP CLOSXP ENVSXP PROMSXP LANGSXP
1 30484 372383 4845 420 180 127274
SPECIALSXP BUILTINSXP CHARSXP LGLSXP INTSXP
203 1168 111430 5296 0 0 44650
REALSXP CPLXSXP STRSXP DOTSXP ANYSXP VECSXP...