<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">What I previously suggested should
work; i.e.,<br>
<br>
big = rbindlist(lapply(fileNameVector, fread, autostart=40))
<br>
big[,y:=y+shift]
<br>
big[,shift:=NULL]
<br>
<br>
just replace 'fileNameVector' with 'sitefiles'. <br>
<br>
<br>
On 06/08/13 16:56, Irucka Embry wrote:<br>
</div>
<blockquote
cite="mid:55425675B955400E89831C4727509420@mail2world.com"
type="cite">
Hi Matthew, how are you?<br>
<br>
Thank you for the notes on fread. I had tried fread to read
sitefiles (see the previous e-mail), but this error message was
returned: <br>
<br>
Error in fread(sitefiles) : <br>
'input' must be a single character string containing a file name,
full path to a file, a URL starting '<a class="moz-txt-link-freetext" href="http://">http://</a>' or '<a class="moz-txt-link-freetext" href="file://">file://</a>', or the
input data itself<br>
<br>
Is there a work around to get fread to read a file path like
sitefiles?<br>
<br>
I was detailing what I was doing with read.table to make sure that
fread could also accomplish those same objectives with the files.<br>
<br>
Thank you.<br>
<br>
Irucka<br>
<br>
<br>
<br>
<-----Original Message-----> <br>
>From: Matthew Dowle [<a class="moz-txt-link-abbreviated" href="mailto:mdowle@mdowle.plus.com">mdowle@mdowle.plus.com</a>]<br>
>Sent: 8/6/2013 3:49:44 AM<br>
>To: <a class="moz-txt-link-abbreviated" href="mailto:iruckaE@mail2world.com">iruckaE@mail2world.com</a><br>
>Cc: <a class="moz-txt-link-abbreviated" href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
>Subject: Re: [datatable-help] data.table on existing
data.frame list<br>
><br>
>On 06/08/13 03:12, iembry wrote:<br>
>> Hi Matthew, thank you for your prompt and great
assistance.<br>
>><br>
>> Yes, moving the autostart = 40 does work. Yes, it did
detect the column<br>
>> names.<br>
>Great.<br>
>><br>
>> In order to read in the .exsa.rdb files I created a
function that follows<br>
>><br>
>> getDataRatingDepotFiles <- function (file, hasHeader =
TRUE, separator =<br>
>> "\t")<br>
>> {<br>
>> RDdatatmp <- as.matrix(read.table(file, sep = "\t",
fill = TRUE,<br>
>> comment.char = "#", header = T, as.is = TRUE,
stringsAsFactors = FALSE,<br>
>> na.strings = "NA", col.names = c("y", "shift", "x",
"stor")))<br>
>> RDdatatmp <- as.matrix(RDdatatmp[c(-1), c(-4)])<br>
>> RDdatatmp <- as.data.frame(RDdatatmp, stringsAsFactors
= FALSE)<br>
>> RDdatatmp$y <- as.numeric(as.character(RDdatatmp$y))<br>
>> RDdatatmp$x <- as.numeric(as.character(RDdatatmp$x))<br>
>> RDdatatmp$shift <-
as.numeric(as.character(RDdatatmp$shift))<br>
>> return(RDdatatmp)<br>
>> }<br>
>><br>
>> I created an object called sitefiles that has the pattern
of the file<br>
>> extension that I want. In the same folder there are files
with two other<br>
>> file extensions that I do not want to use in this
project.<br>
>><br>
>> sitefiles <- list.files(path ="/tried", pattern <-
".exsa.rdb$", full.names<br>
>> = TRUE)<br>
>> getratings <- lapply(sitefiles,
getDataRatingDepotFiles)<br>
>><br>
>> Is there any way to replicate the above with fread?<br>
>I don't follow. fread reads the file. 'select' arg can be used
to <br>
>select columns, or you can use setnames() afterwards to rename
them. <br>
>fread doesn't create factors anyway. The numeric columns
should be <br>
>detected automatically but you can pass 'colClasses' manually
to fread <br>
>if you need to read integer data as a numeric type, in the
latest <br>
>version. Or are you asking if fread can read multiple files?<br>
><br>
><br>
>><br>
>> Irucka<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> The comments are really a banner at the start of the file
it seems. So this<br>
>> is all built in to fread already. But the banner in the
example is 34 rows,<br>
>> so the default of autostart=30 isn't enough. Try:<br>
>><br>
>> fread("03217500.exsa.rsb", autostart=40)<br>
>><br>
>> That should do it in one shot, including detecting the
column names. I've<br>
>> just increased autostart a bit to be within the data
block. See ?fread for<br>
>> a detailed description of autostart and the procedure.<br>
>><br>
>> Btw, if there is more than one table in a single file,
then setting<br>
>> autostart to be within each one is how to read each one
in. And provided<br>
>> there is no footer, you can set autostart to be very
large, too (with<br>
>> downside of time to seek back from the end to find the
column names).<br>
>><br>
>> Matthew<br>
>><br>
>><br>
>><br>
>> --<br>
>> View this message in context:
<a class="moz-txt-link-freetext" href="http://r.789695.n4.nabble.com/data-table-on-existing-data">http://r.789695.n4.nabble.com/data-table-on-existing-data</a>-<br>
>frame-list-tp4673142p4673201.html<br>
>> Sent from the datatable-help mailing list archive at
Nabble.com.<br>
>> _______________________________________________<br>
>> datatable-help mailing list<br>
>> <a class="moz-txt-link-abbreviated" href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
>>
<a class="moz-txt-link-freetext" href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br>
>><br>
><br>
>.<br>
>
<span id="m2wTl">
<p><font style="font-size:13.5px" face="Arial, Helvetica,
sans-serif" size="2">_______________________________________________________________<br>
Get the Free email that has everyone talking at <a
moz-do-not-send="true" href="http://www.mail2world.com"
target="new">http://www.mail2world.com</a><br>
<font color="#999999">Unlimited Email Storage – POP3 –
Calendar – SMS – Translator – Much More!</font></font>
</p>
</span></blockquote>
<br>
</body>
</html>