search for: r_dimnamessymbol

Displaying 12 results from an estimated 12 matches for "r_dimnamessymbol".

2000 Jul 12
1
getAttrib() and setAttrib()
...j]; } PROTECT(dim = allocVector(INTSXP, 2)); INTEGER(dim)[0] = nx; INTEGER(dim)[1] = ny; // setAttrib(ans, R_DimSymbol, dim); PROTECT(dimnames = allocVector(VECSXP, 2)); // VECTOR(dimnames)[0] = getAttrib(x, R_NamesSymbol); // VECTOR(dimnames)[1] = getAttrib(y, R_NamesSymbol); // setAttrib(ans, R_DimNamesSymbol, dimnames); UNPROTECT(3); return(ans); } Here is the output, a vector: > out(c(1,2),c(3,4)) [1] 3 6 4 8 But when I uncomment any one of the 4 lines which use getAttrib() or setAttrib(), R crashes for me, with a Windows message box. Uncommenting the first such line, for example, crashes...
1997 Nov 28
3
R-alpha: Problems with dimnames and names
...-Disposition: attachment; filename="apatch" diff -ur R-0.50-a4/src/main/cov.c R-0.50-a4.patched/src/main/cov.c --- R-0.50-a4/src/main/cov.c Sun Nov 24 23:43:05 1996 +++ R-0.50-a4.patched/src/main/cov.c Fri Nov 28 11:21:23 1997 @@ -390,7 +390,7 @@ } if(isNull(y)) { x = getAttrib(x, R_DimNamesSymbol); - if(!isNull(x) && !isNull(CADR(x))) { + if(ncx > 1 && !isNull(x) && !isNull(CADR(x))) { PROTECT(ind = allocList(2)); CAR(ind) = CADR(x); CADR(ind) = CADR(x); @@ -401,7 +401,7 @@ else { x = getAttrib(x, R_DimNamesSymbol); y = getAttrib(y, R_DimName...
2006 Mar 27
1
Safe to UNPROTECT() when object is assigned to a list?
...l, dim); *** It is safe to do UNPROTECT(1) for 'dim' already here, correct? *** PROTECT(dimnames = allocVector(VECSXP, 2)); SET_VECTOR_ELT(dimnames, 0, getAttrib(x, R_NamesSymbol)); SET_VECTOR_ELT(dimnames, 1, getAttrib(y, R_NamesSymbol)); setAttrib(ans, R_DimNamesSymbol, dimnames); UNPROTECT(3); return(ans); } Thanks /Henrik
1999 Nov 23
2
rbind problem (PR#338)
In the new version 0.90.0, rbind won't take a vector and a matrix from me, but works OK if I coerce the vector to a matrix. The following was run on a new session (i.e., no prior work), and has been duplicated on 2 machines: an SGI running Irix 6.5, and an Intel box running Red Hat Linux 6.0. Either case works fine in version 0.65.1. > t3 <- c(.5, .5) > t4 <-
2006 Nov 17
1
Manipulating R lists in C
...ET_STRING_ELT( volumeStr, 0, mkChar("volume") ); // assign string objects to vector SET_VECTOR_ELT( dimnames, 0, typeStr ); SET_VECTOR_ELT( dimnames, 1, priceStr); SET_VECTOR_ELT( dimnames, 2, volumeStr ); // assign vector to original list of data setAttrib( priceList, R_DimNamesSymbol, dimnames ); <----- I think this is wrong but I don;t know what it should be ===========END EXTRACT=============== -- Dr. Thomas McCallum Systems Architect, Level E Limited ETTC, The King's Buildings Mayfield Road, Edinburgh EH9 3JL, UK Work +44 (0) 131 472 4813 Fax: +44 (0) 131 472 4...
2003 Sep 05
1
Problem with S4 slots in C code (PR#4073)
...e")); SET_STRING_ELT(names, 1, mkChar("year")); SET_STRING_ELT(names, 2, mkChar("sex")); SET_STRING_ELT(names, 3, mkChar("season")); SET_STRING_ELT(names, 4, mkChar("area")); setAttrib(dimnames, R_NamesSymbol, names); setAttrib(v, R_DimNamesSymbol, dimnames); //Set data REAL(v)[0] = 2; //Set slot SET_SLOT(FLQuant, install(".Data"), v); UNPROTECT(10); return FLQuant; } --please do not edit the information below-- Version: platform = i386-pc-mingw32 arch = i386 os = mingw...
2012 Dec 10
1
Changing arguments inside .Call. Wise to encourage "const" on all arguments?
...s a names */ /* attribute. Note that this function mutates x. */ /* Duplication should occur before this is called. */ SEXP DropDims(SEXP x) { SEXP dims, dimnames, newnames = R_NilValue; int i, n, ndims; PROTECT(x); dims = getAttrib(x, R_DimSymbol); [... SNIP ....] setAttrib(x, R_DimNamesSymbol, R_NilValue); setAttrib(x, R_DimSymbol, R_NilValue); setAttrib(x, R_NamesSymbol, newnames); [... SNIP ....] return x; } Well, at least there's a warning comment with that one. But it does show .Call allows call by reference. Why allow it, though? DropDims could copy x, modify the co...
2016 Jun 10
0
collapsing list of NULLs dimnames into a NULL
...ng a list of NULLs as the dimnames of an object, so having dimnames<- do the collapse would fix the problem in one place once for all and avoid a lot of repeated code. Finally, having this functionality available at the C level would be great. Would basically be a wrapper to Rf_setAttrib(x, R_DimNamesSymbol, dimnames) that takes care of the collapse. The SET_DIMNAMES macro could be redefined to call that wrapper instead... Thanks, H. -- Herv? Pag?s Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 P.O. Box 1902...
2003 Dec 17
1
Accessing row and col names of SEXP objects
Can someone lend me a hand with extracting the dimnames from a SEXP? I've looked through R-exts, but I couldn't find an example. Here is the code I'm using to grab the jth column name and print it, but the colnames I'm getting are garbage. None of the following are working. void printInfo(SEXP ts) { int j; for (j=0; j<col; j++) {
1998 Apr 02
1
attributes now inherited
...Dim and Names attributes should have been assigned + elsewhere. */ + SEXP s, t, u; + + PROTECT(inp); + PROTECT(ans); + + for (s=ATTRIB(inp); s!=R_NilValue; s=CDR(s)) { + if ( (TAG(s) != R_NamesSymbol) && + (TAG(s) != R_DimSymbol) && + (TAG(s) != R_DimNamesSymbol) ) { + installAttrib(ans, TAG(s), CAR(s)); + } + } + UNPROTECT(2); + return; + } + static SEXP installAttrib(SEXP vec, SEXP name, SEXP val) { SEXP s, t; ************************************************************************** *** complex.c Wed Sep 17 22:37:02 1997 ---...
2003 May 09
4
getAttr problem
Hi all, It seems that getAttr doesn't return "names" attribute properly as in getAttrib(x, R_NamesSymbol)); If you look at section 4.7.4 in "Writing R Extensions", the second example of SEXP out(SEXP, SEXP) returns NULL for the names attribute of the outer product. This is true for R 1.7.0 on both Win2000 with mingw and Redhat 9.0 with gcc. Is there something I am
2000 Dec 22
2
REading the netCDF format into R
...p. 26 */ INTEGER(dim)[0]=nx; INTEGER(dim)[1]=ny; INTEGER(dim)[2]=nt; setAttrib(field, R_DimSymbol, dim); PROTECT(dimnames = allocVector(VECSXP, 3)); VECTOR(dimnames)[0]="Lon"; VECTOR(dimnames)[1]="Lat"; VECTOR(dimnames)[2]="Time"; setAttrib(field, R_DimNamesSymbol, dimnames); printf("\nfield->%x\nlon -> %x\nlat -> %x\ntim -> %x\nmissing -> %x\n", field,lon,lat,tim,missing); printf("The dimensions are (nx x ny x nt): %d x %d x %d \n",nx,ny,nt); printf("\nCopy into R-objects\n"); /* Copy the data...