"I suspect that you really don't know what 'raw' type means and haven't
bothered to check ?raw. It's also pretty clear that you haven't read the
colClasses description in ?read.table very carefully."

Gee, thanks Peter (this is what I love about the R help boards: people whose
sole goal is to put others down as wittily as possible for asking *stupid
stupid* questions). Gives me warm fuzzies :)

Although I admit to not being the brightest of folks around, or knowing R
backwards and forwards, I did read ?read.table and ?raw. But your suggestion
is not at all helpful Peter:

dat <- read.table(file="data", header=TRUE, colClasses="character") #wow! it
works on a 5x3 matrix! amazing!! (sarcasm)

dat2 <- as.matrix(dat)
storage.mode(dat2) <- 'raw'

if I had wanted 'character' data, I would have put that into my question.
Any newbie can do what you did; the issue is that object.size(dat) is about
8 times larger than object.size(dat2) with any large dataset. That's why I
want to store it as 'raw' - because the raw one takes about 2 Gb RAM and the
other about 16Gb! Perhaps you need to understand the raw mode a bit better,
Peter, because I thought the reason for wanting the data in 'raw' was quite
obvious, but I guess not.

Peter, here's what I want you to do. Use R to make a vector with 2^31 - 5
elements in it. Hey, make it of mode 'character' while you're at it! Write
it out. Read it back in. Having problems? Then come talk to me...

JJ




On Thu, Feb 11, 2010 at 11:36 AM, Peter Ehlers <ehlers@ucalgary.ca> wrote:

> Johan Jackson wrote:
>
>> Hi Don and all,
>>
>> I guess we're getting somewhere. Thanks. The file (first three columns,
>> first five rows) looks like this:
>>
>> X10 X20 X30
>> 00   00    01
>> 00   02   02
>> 00   00  00
>> 00   01  01
>> 00  00  00
>>
>>
>> I guess R is reading 00 as a character? But here's the weird thing: this
>> data (a raw matrix in R) was written out by R itself:
>>
>> write.table(dat,"data",col.names=T,row.names=F,quote=F)
>>
>> *If* I understand correctly, then this seems like very *bad behavior* on
>> R's
>> part: you should be able to write out a matrix and read it right back into
>> R
>> without hassles like this (but everytime I blame R, it turns out to be
>> user
>> error, so...),
>>
>> JJ
>>
>
> Well, R is stupid, of course, so there's not much sense in
> blaming R. You could blame the designers/programmers, but I
> wouldn't do that - they seem like pretty smart people.
>
> Still, I can sympathize. When I first got my Porsche, I
> couldn't figure out how to make it go faster and why it
> kept making so much noise. Then someone told me that the
> left foot pedal wasn't just a footrest. And thus I discovered
> that there are non-automatics in this world. -:)
>
> Anyway, I just read your sample data into R, saved it with
> your write() command and read it back with
>
>  dat <- read.table(file="data", header=TRUE, colClasses="character")
>
> I suspect that you really don't know what 'raw' type means
> and haven't bothered to check ?raw. It's also pretty clear
> that you haven't read the colClasses description in
> ?read.table very carefully. The one thing R help pages are
> pretty good at is careful definition of arguments.
>
> I do hope that your day will improve.
>
>  -Peter Ehlers
>
> [......]
>
>
> --
> Peter Ehlers
> University of Calgary
>
>

	[[alternative HTML version deleted]]

