Displaying 20 results from an estimated 1400 matches similar to: "subRaw?"
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 <- character(0)
>
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 <-
2007 Aug 31
1
Consistency of serialize(): please enlighten me
Hi,
I am puzzled with serialize(). It comes down generating identical
hash codes for (apparently) identical objects using digest::digest(),
which in turn relies on serialize(). Here is an example illustration
the issue:
ser <- function(object, ...) {
list(
names = names(object),
namesRaw = charToRaw(names(object)),
ser = serialize(names(object), connection=NULL, ascii=FALSE)
2013 May 08
1
getting corrupted data when using readBin() after seek() on a gzfile connection
Hi,
I'm running into more issues when reading data from a gzfile connection.
If I read the data sequentially with successive calls to readBin(), the
data I get looks ok. But if I call seek() between the successive calls
to readBin(), I get corrupted data.
Here is a (hopefully) reproducible example. See my sessionInfo() at the
end (I'm not on Windows, where, according to the man page,
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
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
2018 Feb 17
1
writeLines argument useBytes = TRUE still making conversions
Of course, right after writing this e-mail I tested on my Windows
machine and did not see what I expected:
> charToRaw(before)
[1] c3 a9
> charToRaw(after)
[1] e9
so obviously I'm misunderstanding something as well.
Best,
Kevin
On Sat, Feb 17, 2018 at 2:19 PM, Kevin Ushey <kevinushey at gmail.com> wrote:
> From my understanding, translation is implied in this line of ?file
2010 Jan 14
1
memDecompress and zlib compressed base64 encoded string
Hi,
I have zlib compressed strings (example is attached) and would like to
decompress them using memDecompress ...
I try this:
> connection <- file("compressed.txt","r")
> compressed <- readLines(connection)
> memDecompress(as.raw(compressed),type="g")
Error in memDecompress(as.raw(compressed), type = "g") :
internal error -3 in
2010 Jul 09
2
Compress string memCompress/Decompress
Hello,
I would like to compress a long string (character vector), store the compressed string in the text field of a SQLite database (using RSQLite), and then load the text back into memory and decompress it back into the the original string. My character vector can be compressed considerably using standard gzip/bzip2 compression. In theory it should be much faster for me to compress/decompress
2018 Feb 15
2
writeLines argument useBytes = TRUE still making conversions
On Thu, Feb 15, 2018 at 11:19 AM, Kevin Ushey <kevinushey at gmail.com> wrote:
> I suspect your UTF-8 string is being stripped of its encoding before
> write, and so assumed to be in the system native encoding, and then
> re-encoded as UTF-8 when written to the file. You can see something
> similar with:
>
> > tmp <- '?'
> > tmp <- iconv(tmp,
2010 Jul 27
2
Match() on raw objects ?
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?...
Nom : non disponible
URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20100727/2e19110f/attachment.pl>
2023 Apr 13
1
Split String in regex while Keeping Delimiter
Dear Emily,
Using a look-behind solves the split problem in this case. (Note: Using
Regex is in most/many cases the simplest solution.)
str = c("leucocyten + gramnegatieve staven +++ grampositieve staven ++",
"leucocyten ? grampositieve coccen +")
tokens = strsplit(str, "(?<=[-+])\\s++", perl=TRUE)
PROBLEM
The current expression does NOT work for a different
2013 May 01
1
Windows, format.POSIXct and character encodings
Hi all,
In what encoding does format.POSIXct return its output? It doesn't
seem to be utf-8:
Sys.setlocale("LC_ALL", "Japanese_Japan.932")
times <- c("1970-01-01 01:00:00 UTC", "1970-02-02 22:00:00 UTC")
ampm <- format(as.POSIXct(times), format = "%p")
x <- gsub(">", "*", paste(ampm, collapse =
2010 Jul 21
3
String processing - is there a better way
I have a two part question
Part 1)
I am trying to remove characters in a string based on the position of a key character in another string.? I have a solution that works but it requires a for-loop.? A vectorized way of doing this has alluded me.?
CleanRead<-function(x,y) {
? if (!is.character(x))
??? x <- as.character(x)
? if (!is.character(y))
??? y <- as.character(y)
?
2006 May 12
1
DICOM package wont read my DICOM files
Hello there!
I hope there is someone out there who is using the DICOM package.
When Im trying to read my a DICOM file (MRI-data) I always get this
error:
> dicom.info("~/myfile")
Error in readBin(fid, integer(), length, size = 1) :
invalid value of 'n'
The DICOM files that come with the DICOM package work just fine.
I already tried both endian options.
I can view my
2018 Feb 15
2
writeLines argument useBytes = TRUE still making conversions
I think this behavior is inconsistent with the documentation:
tmp <- '?'
tmp <- iconv(tmp, to = 'UTF-8')
print(Encoding(tmp))
print(charToRaw(tmp))
tmpfilepath <- tempfile()
writeLines(tmp, con = file(tmpfilepath, encoding = 'UTF-8'), useBytes = TRUE)
[1] "UTF-8"
[1] c3 a9
Raw text as hex: c3 83 c2 a9
If I switch to useBytes = FALSE, then
2010 Dec 07
3
More elegant magnitude method
I have a need to find the order of number to get a scaling parameter as a
power of 10. I have a function that works *so far*, but it is ugly and
probably buggy. In the interest of avoiding code-based outliers in my
data, I thought I would ask if anyone here has a better way.
> scl <- function(x){
+ length(charToRaw(format(trunc(x), scientific = F)))-1}
> a <- 123456789
> b <-
2008 Feb 25
3
How to include the documentation of a function in a Sweave document?
Dear R-help,
I would like to include the documentation of an R function in an
*.rnw document processed by Sweave. Because I'm sharing my *.rnw
files with colleagues under Linux and Windows (I'm on Mac OS X),
I would like a pure R solution.
The naive approach doesn't work, because Sweaving this *.rnw
file:
-------- tmp.rnw --------
\documentclass{article}
\begin{document}
2009 Aug 29
2
RFE: vectorize URLdecode
In R 2.9.2,
> URLdecode(c("a%20b", "b%20c"))
[1] "a b"
Warning message:
In charToRaw(URL) : argument should be a character vector of length 1
all but the first element will be ignored
Could URLdecode be modified to actually process all elements of the vector, not
just the first?
Thanks in advance
2009 Aug 06
10
GE centricity viewer??
I picked up some data from the nearest hospital to take to the
specialist at the next one, with whom I had an appt.; it came on a CD,
which is marked "DICOM Volume with GE Centricity Viewer."
When I put the CD into a drive, Fedora 11 auto-mounts it, and
fails to find the autorun.exe, which is right there in plain sight. (F11
knows it exists, and asks whether to run it, and then