Displaying 10 results from an estimated 10 matches for "lengthgets".
Did you mean:
lengthens
2003 Dec 12
3
C++: Appending Values onto an R-Vector.
Hi folks. I posted this question a few days ago, but maybe it got lost
because of the code I included with it. I'm having a problem using the
SET_LENGTH() macro in an R extension I'm writing in C++. In a function
within the extension I use SET_LENGTH() to resize R vectors so as to
allow the concatenation of single values onto the vectors -- it's a
"push back" function to
2005 Sep 18
0
Updated rawConnection() patch
...failed"),
+ isText ? "text" : "raw");
}
static void outtext_close(Rconnection con)
{
Routtextconn this = (Routtextconn)con->private;
- SEXP tmp;
- int idx = ConnIndex(con);
+ SEXP tmp, rm;
if(strlen(this->lastline) > 0) {
- PROTECT(tmp = lengthgets(this->data, ++this->len));
- SET_STRING_ELT(tmp, this->len - 1, mkChar(this->lastline));
- defineVar(this->namesymbol, tmp, VECTOR_ELT(OutTextData, idx));
- this->data = tmp;
+ PROTECT(tmp = lengthgets(this->data, this->len+1));
+ SET_STRING_ELT(tmp, this->len, mkChar(thi...
2005 Apr 16
1
SET_LENGTH
Hello.
I'm trying to read a delimited file. I'm a little new
to the R api. In the program, I do something like
this...
/*****************************/
SEXP retval;
PROTECT(retval = allocMatrix(STRSXP,1,names.dim));
int r_eltctr = 0;
while(!myfile.eof())
{
SET_LENGTH(retval,r_eltctr+num_of_fields);
for(int i = 0;numofcolumns; ++i)
{
INTEGER(retval)[r_eltctr++] = 1;/*some
2005 Aug 29
1
Question about SET_LENGTH
Hello all, thanks for all the help on the other issues. This one should
be relatively straightforward. I have a vector of integers which I
allocate to be the maximal size possible (meaning I'll never see more
than cel.GetNumOutliers, but most likely I'll see less) therefore, I
want to resize the vector, one solution would be to allocate a new
vector then to copy into the new vector. That
2005 Apr 03
2
Error: cannot set length of non-vector
The subject line says it all. How can I find what
Error: cannot set length of non-vector
means? RTFS is no help. I can find out of course that
it comes from "lengthgets", but who called that? Not me!
The situation is as follows. I am trying to get a package
ready for CRAN. Every time I run "R CMD check" I get this
error when building the package vignette. But (!)
"R CMD build" has no complaints and neither does "Sweave"
when...
2010 Mar 11
1
Shrinking a List
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 M and /duplicate/ the
elements of A.
Since I do this often, it appears to be wasteful,
2000 Apr 01
1
Bug ? mine or ? in R core
Dear R Gurus,
I would very much appreciate some help with this code snippit
from my RODBC package.
R crashes or exhibits bizarre behaviour when repeatedly fetching
large numbers of rows.
Examples:
> odbcFetchRows(0,max=50000)->xx
> odbcFetchRows(0,max=50000)->xx
> odbcFetchRows(0,max=50000)->xx
> odbcFetchRows(0,max=50000)->xx
> odbcFetchRows(0,max=50000)->xx
3rd
2008 Apr 29
2
reproducible segmentation fault caused by textConnection()
Dear all,
It seems that textConnection() can trigger a segmentation fault. The
following script (using two large loops) makes this bug reproducible:
for (i in 1:10000) {
z=textConnection(NULL,open='w')
for (j in 1:100) {
write(runif(1)*1e6,file=z)
write('\n',file=z)
}
close(z)
}
The bug could be reproduced on R-2.6.1, R-2.7.0 and on the latest
R-devel
2007 Jan 19
5
Problem with C extension
Hello,
I try to write an extension in C, to get a faster functions.
Therefore I have to add an element (vector) to a vector. The command in
R is very simple: x = c(x,a)
But in C I have the problem to reallocate my vector for getting more
space. Everything I tried, I get a "Segmentation fault".
So, how can I combine two vectors in C and give the result back to R
(return(x))?
Thanks
2005 Aug 22
2
RFC: "loop connections"
...return res;
}
-static void outtext_init(Rconnection con, char *mode, int idx)
+static size_t raw_write(const void *ptr, size_t size, size_t nitems,
+ Rconnection con)
+{
+ Routloopconn this = (Routloopconn)con->private;
+ SEXP tmp;
+ int idx = ConnIndex(con);
+
+ PROTECT(tmp = lengthgets(this->data, this->len + size*nitems));
+ memcpy(RAW(tmp)+this->len, ptr, size*nitems);
+ this->len += size*nitems;
+ defineVar(this->namesymbol, tmp, VECTOR_ELT(OutTextData, idx));
+ this->data = tmp;
+ UNPROTECT(1);
+ return nitems;
+}
+
+static void outloop_ini...