Bug 8529 - rbind/cbind unimplemented for raw (RAWSXP) types.
Summary: rbind/cbind unimplemented for raw (RAWSXP) types.
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: old
Hardware: All Linux-Fedora
: P5 normal
Assignee: Jitterbug compatibility account
URL:
Depends on:
Blocks:
 
Reported: 2006-01-27 20:26 UTC by Jitterbug compatibility account
Modified: 2006-01-27 20:46 UTC (History)
0 users

See Also:


Attachments
(1.30 KB, text/x-patch)
2006-01-27 20:46 UTC, Jitterbug compatibility account
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jitterbug compatibility account 2006-01-27 20:26:47 UTC
From: hin-tak.leung@cimr.cam.ac.uk
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

Comment 1 Jitterbug compatibility account 2006-01-27 20:46:01 UTC
From: Hin-Tak Leung <hin-tak.leung@cimr.cam.ac.uk>
PARTS: 2
hin-tak.leung@cimr.cam.ac.uk 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));
================================

(Attached 'bind-rawsxp.patch' of type 'text/x-patch')

**END
Comment 2 Jitterbug compatibility account 2006-01-27 20:46:01 UTC
Created attachment 991 [details]
Comment 3 Jitterbug compatibility account 2006-01-28 16:42:00 UTC
NOTES:
 patch incorporated in 2.3.0
Comment 4 Jitterbug compatibility account 2006-01-28 17:43:49 UTC
Audit (from Jitterbug):
Sat Jan 28 11:42:54 2006	ripley	changed notes
Sat Jan 28 11:43:49 2006	ripley	moved from incoming to Low-level-fixed