From h.wickham at gmail.com  Wed Aug 28 19:59:07 2013
From: h.wickham at gmail.com (Hadley Wickham)
Date: Wed, 28 Aug 2013 12:59:07 -0500
Subject: [Rd] Memory allocation in read.table
In-Reply-To: <6603B703-48C9-417E-9495-F68B4015F381@r-project.org>
References: <CABdHhvEtVhBQS7x+S86my3ec26-iCQx+NpVdzM4nh5ca=pGfqg@mail.gmail.com>
	<6603B703-48C9-417E-9495-F68B4015F381@r-project.org>
Message-ID: <CABdHhvE9LrcseP93KTG4AtkrgffDF9FgkQH-kBnP_fgJRt+i8w@mail.gmail.com>

>> Why do those lines need any allocations? I thought class<- and attr<-
>> were primitives, and hence would modify in place.
>>
>
> .. but only if there is no other reference to the data (i.e. NAMED < 2). If there are two references, they have to copy, because it would change the other copy.
> Here, however, it already has NAMED=2 because of
>
> data <- data[keep]

Ah, got it - thanks!

> PS: if you are loading any sizable data, the one thing you don't want to do is to use read.table() ;)

Yes ;)  Romain and I (mostly Romain) are working on some faster
alternatives at https://github.com/romainfrancois/fastread.

One surprising finding so far (to me at least), is that when loading a
file full of doubles, you pretty quickly get to the point where strtod
is the bottleneck.

Hadley

-- 
Chief Scientist, RStudio
http://had.co.nz/



[Rd] Memory allocation in read.table
Hadley Wickham