[R] help to make a map on R
Magnus Lie Hetland
magnus at hetland.org
Wed Oct 2 23:30:51 CEST 2002
Ronaldo Reis Jr. <chrysopa at insecta.ufv.br>:
>
> Hi all,
> I need a little help for construct an state's map on R.
>
> The first problem is to get the data.
>
> I have a datafile of longitude and latitude in the follow format:
[snip]
> To read a file is simple, but I need that R change the value of
> trajectory after a blank line, reading something like this:
> Each trajectory is a line that is a little piece of my map.
[snip]
Not sure if this is heresy ;) but this sort of thing would be very
easy to do with a programming language such as Python, Ruby, or Perl
(or even awk) as a preprocessing step.
For example (in Python):
----------------------------------------------------------------------
num = 1
lines = iter(open('map.data'))
print lines.next(),
for line in lines:
if line.isspace():
num += 1
else:
fields = line.split()
fields[0] += str(num)
print '\t'.join(fields)
----------------------------------------------------------------------
Just a thought :)
--
Magnus Lie Hetland Practical Python The Anygui Project
http://hetland.org http://ppython.com http://anygui.org
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list