rbind/cbind unimplemented for raw (RAWSXP) types. (PR#8529)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

rbind/cbind unimplemented for raw (RAWSXP) types. (PR#8529)

Hin-Tak Leung-2
Full_Name: Hin-Tak Leung
Version: R 2.2.1
OS: x86_64-redhat-linux-gnu
Submission from: (NULL) (131.111.186.92)


rbind/cbind is unimplemented for raw (RAWSXP) types.

I have a working patch implementing the functionality,
to follow.

--please do not edit the information below--

Version:
 platform = x86_64-redhat-linux-gnu
 arch = x86_64
 os = linux-gnu
 system = x86_64, linux-gnu
 status =
 major = 2
 minor = 2.1
 year = 2005
 month = 12
 day = 20
 svn rev = 36812
 language = R

Locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C

Search Path:
 .GlobalEnv, package:methods, package:stats, package:graphics,
package:grDevices, package:utils, package:datasets, Autoloads, package:base

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: rbind/cbind unimplemented for raw (RAWSXP) types. (PR#8529)

Hin-Tak Leung-2
[hidden email] wrote:

> Full_Name: Hin-Tak Leung
> Version: R 2.2.1
> OS: x86_64-redhat-linux-gnu
> Submission from: (NULL) (131.111.186.92)
>
>
> rbind/cbind is unimplemented for raw (RAWSXP) types.
>
> I have a working patch implementing the functionality,
> to follow.
Attached in ready-to-patch form and also insert (white spaces
will go wrong) here. Please review, comment and possibly commit,
and hope to see it in R 2.3.x

====================
--- src/main/bind.c.orig        2005-10-06 11:25:22.000000000 +0100
+++ src/main/bind.c     2006-01-27 11:55:32.000000000 +0000
@@ -997,6 +997,7 @@
      case CPLXSXP:
      case STRSXP:
      case VECSXP:
+    case RAWSXP:
         break;
         /* we don't handle expressions: we could, but coercion of a matrix
            to an expression is not ideal */
@@ -1164,6 +1165,18 @@
             }
         }
      }
+    else if (mode == RAWSXP) {
+       for (t = args; t != R_NilValue; t = CDR(t)) {
+           u = PRVALUE(CAR(t));
+           if (isMatrix(u) || length(u) >= lenmin) {
+               u = coerceVector(u, RAWSXP);
+               k = LENGTH(u);
+               idx = (!isMatrix(u)) ? rows : k;
+               for (i = 0; i < idx; i++)
+                   RAW(result)[n++] = RAW(u)[i % k];
+           }
+       }
+    }
      else {
         for (t = args; t != R_NilValue; t = CDR(t)) {
             u = PRVALUE(CAR(t));
@@ -1385,6 +1398,21 @@
             }
         }
      }
+    else if (mode == RAWSXP) {
+       for (t = args; t != R_NilValue; t = CDR(t)) {
+           u = PRVALUE(CAR(t));
+           if (isMatrix(u) || length(u) >= lenmin) {
+               u = coerceVector(u, RAWSXP);
+               k = LENGTH(u);
+               idx = (isMatrix(u)) ? nrows(u) : (k > 0);
+               for (i = 0; i < idx; i++)
+                   for (j = 0; j < cols; j++)
+                       RAW(result)[i + n + (j * rows)]
+                           = RAW(u)[(i + j * idx) % k];
+               n += idx;
+           }
+       }
+    }
      else {
         for (t = args; t != R_NilValue; t = CDR(t)) {
             u = PRVALUE(CAR(t));
================================

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel