<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
James Nylen a écrit :
<blockquote
cite="mid:205a4c310811170842i95c5174qb9f32fa14c43c5ad@mail.gmail.com"
type="cite">
<div>The easiest thing to do is probably to write the data.frame to a
tab-delimited text file using write.table and then read in the written
file like you have done above. See ?write.table - as I recall there
are plenty of options that will allow you to specify the separator,
whether or not to write headings, etc.</div>
<div> </div>
<div>-James</div>
</blockquote>
This is exactly what I did yesterday (see script below - the function
uploadEtrex is now at the working stage in a package pgirbirc at
<a class="moz-txt-link-freetext" href="http://pagesperso-orange.fr/giraudoux/">http://pagesperso-orange.fr/giraudoux/</a> or
<a class="moz-txt-link-freetext" href="http://pagesperso-orange.fr/giraudoux/#pgirbric">http://pagesperso-orange.fr/giraudoux/#pgirbric</a>)<br>
<br>
However when I think about it, my question was a bit silly: it was
something as how to send a r-object to a connexion that a batch script
could read at the operating system level without writing a file on
disk... I guess there is no solution and the easiest way, indeed, is to
write a text file and make it read from the shell (which is what the
current fonction does...).<br>
<br>
Thanks anyway for your input,<br>
<br>
Patrick<br>
<br>
<br>
uploadEtrex <- function (df, wcom = 4) <br>
{<br>
dff <- as.data.frame(matrix(NA, nrow = nrow(df), ncol = 9))<br>
dff[, c(2, 8, 9)] <- df[, c(1, 3, 2)]<br>
write.table(dff, "dff", col.names = FALSE, sep = "\t", quote =
FALSE)<br>
if (Sys.info()["sysname"] != "Windows") {<br>
system(paste("gpsbabel -w -i tabsep -f dff -o garmin -F
/dev/ttyUSB0", <br>
sep = ""))<br>
}<br>
else {<br>
system(paste("gpsbabel -w -i tabsep -f dff -o garmin -F com", <br>
wcom, ":", sep = ""))<br>
}<br>
}<br>
<br>
<blockquote
cite="mid:205a4c310811170842i95c5174qb9f32fa14c43c5ad@mail.gmail.com"
type="cite">
<div><br>
<br>
</div>
<div><span class="gmail_quote">On 11/16/08, <b
class="gmail_sendername">Patrick Giraudoux</b> <<a
moz-do-not-send="true" href="mailto:patrick.giraudoux@univ-fcomte.fr">patrick.giraudoux@univ-fcomte.fr</a>>
wrote:</span>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">Dear
listers,<br>
<br>
I am writing a R function to upload waypoints to a GPS Garmin Etrex
with gpsbabel. This works quite well reading from a text file as
following:<br>
<br>
df<-"mytabfile.txt"<br>
system(paste("gpsbabel -w -i tabsep -f ",df," -o garmin -F
com5:",sep=""))<br>
<br>
However, I would prefer to upload from a data.frame within R rather
than reading a tab delimited text file on the disk.<br>
<br>
Any idea about how to specify it in the command line (should be
trivial, but I cannot figure it out) ?<br>
<br>
Thanks in advance,<br>
<span class="sg"><br>
Patrick<br>
<br>
<br>
</span><br>
_______________________________________________<br>
R-sig-Geo mailing list<br>
<a moz-do-not-send="true"
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:R-sig-Geo@stat.math.ethz.ch">R-sig-Geo@stat.math.ethz.ch</a><br>
<a moz-do-not-send="true"
onclick="return top.js.OpenExtLink(window,event,this)"
href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br>
<br>
<br clear="all">
</blockquote>
</div>
<br>
</blockquote>
<br>
</body>
</html>