search for: rawtochar

Displaying 20 results from an estimated 53 matches for "rawtochar".

2008 May 21
1
rawToChar(raw(0))
Hi, right now we have (on R v2.7.0 patched (2008-04-23 r45466)) that: > rawToChar(raw(0)) [1] "" > rawToChar(raw(0), multiple=TRUE) character(0) Is this intended or should both return character(0)? Personally, I would prefer that an empty input vector returns an empty output vector. Same should then apply to charToRaw(), but right now we get: > x <- charac...
2008 Apr 28
4
R 2.7.0, match() and strings containing \0 - bug?
Hi, A piece of my code that uses readBin() to read a certain file type is behaving strangely with R 2.7.0. This seems to be because of a failure to match() strings after using rawToChar() when the original was terminated with a "\0" character. Direct equality testing with == still works as expected. I can reproduce this as follows: > x <- "foo" > y <- c(charToRaw("foo"),as.raw(0)) > z <- rawToChar(y) > z==x [1] TRUE > z==&quot...
2007 Aug 07
2
Embedded nuls in strings
Hi, ?rawToChar 'rawToChar' converts raw bytes either to a single character string or a character vector of single bytes. (Note that a single character string could contain embedded nuls.) Allowing embedded nuls in a string might be an interesting experiment but it seems to cause some trou...
2013 May 08
1
getting corrupted data when using readBin() after seek() on a gzfile connection
...(con) ## Read the data from test.gz file. We'll read blocks of 26 bytes ## located at various offsets that are multiple of 26, so we expect ## to see our original pattern ("abc...xyz"). con <- gzfile("test.gz", open="rb") ## Offset 0: ok > rawToChar(readBin(con, "raw", n=26)) [1] "abcdefghijklmnopqrstuvwxyz" ## Offset 78: still ok > seek(con, where=78) [1] 26 > seek(con) [1] 78 > rawToChar(readBin(con, "raw", n=26)) [1] "abcdefghijklmnopqrstuvwxyz" ## Offset 520: dat...
2013 May 03
1
untar() error
...he details are below, and any help in solving this matter is appreciated. > files = list.files(path = "J:/GIMMS/NDVI", pattern = "data.tif.gz", all.files = TRUE, full.names = TRUE, recursive = TRUE, ignore.case = TRUE, include.dirs = TRUE) > lapply(files, untar) Error in rawToChar(block[seq_len(ns)]) : embedded nul in string: 'II*\0Ì <\001´ \0\0`G\0\0\fn\0\0¸”\0\0d»\0\0\020â\0\0¼\b\001\0h/\001\0\024V\001\0À|\001\0l£\001\0\030Ê\001\0Äð\001\0p\027\002\0\034>\002\0Èd\002\0t‹\002\0 ²\002\0ÌØ\002\0xÿ\002\0$&\003\0ÐL\003\0|s\003' > untar(files[1]) Error in...
2013 Jul 15
2
Serialize data.frame to database
...", data.bin, "')", sep = "")) data.bin2 <- dbGetQuery(db, "SELECT DATA FROM frames WHERE simID = 1") data.bin2 data 1 58 So, only the first entry of data.bin is saved to the database. I tried to first convert the binary data to raw data: data.raw <- rawToChar(data.bin) Error in rawToChar(data.bin) : embedded nul in string: 'X\n\0\0\0\002\0\003\0\001\0\002\003\0\0\0\003\023\0\0\0\005\0\0\0\016\0\0\0\x96@\024ffffff@\023\x99\x99\x99\x99\x99\x9a@\022\xcc\xcc\xcc\xcc\xcc\xcd@\022ffffff@\024\0\0\0\0\0\0@\025\x99\x99\x99\x99\x99\x9a@\022ffffff@\024\0\0\0...
2011 Apr 19
1
print.raw - but convert ASCII?
Does anyone know if there is a simple way to print raw vectors, such that ASCII characters are printed for bytes in the ASCII range, and their hex representation otherwise? rawToChar doesn't work when we have something like c(0x00, 0x00, 0x44, 0x00). -Matt
2013 Apr 10
1
Issue with Control-Z in a text file on Windows - readLines() appears to truncate
...26 in decimal, and the readLines() function in R on Windows (2.15.2 and 3.0.0) appears to truncate at the control-Z. There is no problem at all on Ubuntu Linux with R 3.0.0. Am I mistaken or is this genuine? # Create a small file with embedded Control-Z h3 <- paste('1,34,44.4,"', rawToChar(as.raw(c(65, 26, 65))), '",99') h3 # "1,34,44.4,\" A\032A \",99" writeLines(h3, 'h3.txt') # now attempt to read the file back in h3a <- readLines('h3.txt') # but on Windows 2.15.2 and 3.0.0 I get the message #Warning message: #In readLines(&quot...
2008 Oct 28
2
writting null (\000 or ^@) to an external text file without the new warning
I have some functions that write an external text file for postprocessing by another program. Some instructions to the other program need to be indicated by null values (\000 or ^@). The function currently uses code like: writeChar(rawToChar(as.raw(0)), con) where con is a connection to the file. Previous to version 2.8.0 this worked fine. With 2.8.0 it still works, but I get a warning message about "truncating string with embedded null: '\0'" every time. This is documented and not a bug, but I still find it annoy...
2010 Dec 14
1
Installing R-packages in Windows
...tting a weird error. No matter which package I am trying to install - I nearly get the same error. It looks like this: ----------------------------------------------------------------------------- C:\Program Files\R\R-2.10.0\bin>R CMD INSTALL %SystemDrive%\rPAcsTemp\car_2.0-2. zip Warning in rawToChar(block[seq_len(ns)]) : truncating string with embedded nul: 'PK\003\004\n\0\0\0\0\01??G=\0\0\0\0\0\0\0 \0\0\0\0\0\004\0\0\0car/PK\003\004\n\0\0\0\0\0-??G=\0\0\0\0\0\0\0\0\0\0\0\0\t\0\0 \0car/data/PK\003\004\024\0\002\0\b\0-??G=+2&??[\t\003\0??-\003\0\022' Warning in rawToChar(block[1...
2008 Sep 25
1
Saving R-objects to a database
Someone solved the problem of saving R-objects to a database? These are the two varaints I've tried so far without success: 1) ser = rawToChar(serialize(obj, NULL, ascii=TRUE)) dbSendQuery(link, paste("insert into table values(1, '",ser,"')",sep='')) The field to save the object in the MySQL Database is of type text. unser = dbGetQuery(link,"select * from table where id=1") Warning message:...
2009 May 10
2
In C, a fast way to slice a vector?
Hello, Suppose in the following code, PROTECT(sr = R_tryEval( .... )) sr is a RAWSXP vector. I wish to return another RAWSXP starting at position 13 onwards (base=0). I could create another RAWSXP of the correct length and then memcpy the required bytes and length to this new one. However is there a more efficient method? Regards Saptarshi Guha
2006 Sep 05
1
serialize changes for 2.4.0
...n14\n1\n1\n14\n1\n2\n14\n1\n3\n" > but in R 2.4.0 alpha I get > serialize(list(1,2,3), NULL, ascii = TRUE) [1] 41 0a 32 0a 31 33 32 30 39 36 0a 31 33 31 38 34 30 0a 31 39 0a 33 0a 31 34 [26] 0a 31 0a 31 0a 31 34 0a 31 0a 32 0a 31 34 0a 31 0a 33 0a > It seems I need to use 'rawToChar()' to get the character vector that I used to get in R 2.3.1. Is this intentional? I couldn't find any mention of this change in the NEWS file; from the docs, it seems to me that either return value could be correct. > version _ platform x86_64-unknown-linux-g...
2011 Oct 21
2
Change column/row-name
...ng: (Iske <- matrix(c(1, 1, 1, 2, 2, 2, 1, 1, 1, 5, 1, 2, 2, 2, 1, 1, 1, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2), ncol = 5)) #My Matrix Iske<- Iske+33 #I want see the letters (Iske.char<-apply(Iske, 1, function(x) rawToChar(as.raw(x)))) #Numbers to Char LD <- function(s1, s2){ require(vwr) s1 = as.character(s1) s2 = as.character(s2) t(sapply(s1, levenshtein.distance, s2)) } Iske.levens<-(LD(Iske.char,Iske.char)) #Calculate the Levenshtein-Distanz The result: !"#$% !"#$% !"#$% &quo...
2016 Sep 05
2
How to print UTF-8 encoded strings from a C routine to R's output?
Dear R experts, It seems that Rprintf has to be used to print from a C routine to guarantee to write to R?s output according to https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Printing. However if a string is UTF-8 encoded, non-ASCII characters (e.g., the infinity symbol http://www.fileformat.info/info/unicode/char/221e/index.htm) are misprinted. Is this an unsupported feature or is
2012 Sep 19
2
Rcmd check problem
...mpt and used the following commands in building my package Rcmd check myPackageName Rcmd build myPackageName Rcmd check myPackageName.tar.gz Rcmd INSTALL --build myPackageName.tar.gz Rcmd check myPackageName.zip The last check command return me an error Rcmd check myPackageName.zip Error in rawToChar(block[seq_len(ns)]) : embedded nul in string: 'PK\003\004\n\0\0\0\0\0}?1A\0\0\0\0\0\0\0\0\0\0\0\0\f\ 0\0\0myPackageName/PK\003\004\n\0\0\0\0\0y?1A\0\0\0\0\0\0\0\0\0\0\0\0\021\0\0\0myPackageName/demo/PK\003\004\024\0\002\0\b\0y' Execution halted I do not know what it means. On the other h...
2013 Apr 03
1
Question: how to convert raw to numeric
I know that there is a function to convert binary data to string named rawToChar.but I wander is there any similar function for "Integer" and "float".I need to read some binary file in "integer" and "float" data. I can do this job in this way: (as below) first convert 4 byte raw to bits then pack bits back to "integer", but it...
2012 Nov 04
1
what is the function naming convention?
...e.dcf (etc) The manual "Creating R Packages" states that it depends on the classes and instances. I couldn't find more hints. And there's more: - using underscore characters: check_tzones, Cstack_info, R_system_version (etc) - using interCapping: closeAllConnections, rawToChar, rowSums, toString, tryCatch, writeLines (etc) - using dots and intercapping: as.Date, julian.Date, toString.default (etc) So, an entire zoo of function names. Did I miss a system, or is it arbitrary (within the set of accepted characters) ? What is the best way to name one's own...
2007 Aug 31
1
Consistency of serialize(): please enlighten me
...); # 1. As is d[[1]] <- ser(key); # 2. Set names and redo (hardwired: identical to what's already there) names(key) <- "abc"; d[[2]] <- ser(key); # 3. Set names and redo (generic: char->raw->char) key <- key0; names(key) <- sapply(names(key), FUN=function(name) rawToChar(charToRaw(name))); d[[3]] <- ser(key); # All names are identical for (kk in 2:length(d)) stopifnot(identical(d[[1]]$names, d[[kk]]$names)); # All raw names are identical for (kk in 2:length(d)) stopifnot(identical(d[[1]]$namesRaw, d[[kk]]$namesRaw)); # But, the serialized names differ. pr...
2009 Oct 23
2
reg-tests-1.R failure with unstable
Hi, I am getting an error from one of the test files tests/reg-tests-1.R using the unstable version (r50179). (i've learned my lessons; this is a clean build.) The tail of reg-tests-1.Rout.fail is Loading required package: myTst building package pkgA ... installing package pkgA using file pkgA_1.0.tar.gz ... Error in as.octmode(mode) : invalid digits Error in install.packages(r, lib =