[R] how to do java-like hashtables in R, R from a java programmer's p onit of view
chrism at norcomnetworks.com
Wed Apr 25 19:22:42 CEST 2001
I suppose I am looking for recommendations on the right book on R for me.
This post drones on a bit about what sort of programming I do and is
basically asking if there are any books on R written with me in mind. I
also make a proposal regarding R documentation at the end.
I started reading "Programming with Data," by Chambers, got really excited
in chapter 1, then found that I had a hard time learning what I wanted to
know from the rest of it.
I have been reading "An Introduction to R," which is quite good, but stops
short of what I want to know. My company operates a satellite mobile data
network and I am the "chief traffic analysist," you might say. I have a
packet sniffer that captures a complete record of every packet that goes
over the air in our network and from that, I study the system's capacity, do
troubleshooting, and all sorts of other analysis. I plot things like
channel utilisation versus time during the day, arrival and departure rates
of calls in the system, arrival rates of different categories of packets,
and many other things. I am no statistician (I'm a communictions theory guy
who enjoys programming).
I have written a lot of software to analyze the raw data in java and I am
very attracted to R's interactive ploting and data analysis abilities. I am
having a hard time making the connection between how I usually do things in
java and how to do things in R, however.
After I got the basic syntax of R down, one of the first questions I asked
myself was."O.K., now how do I build a hashtable from a text file?"
I took me a while to realize that R's lists are one way to do that.
For example, suppose I have a text file with the following key/value pairs
and I want to read this into a hash table. I must have written a dozen
programs that do any number of variations on this basic task in the last
year or so. I can't believe how useful it is.
In R, you might proceed as follows to build such a table. Say x is some
list object. Say you have a loop that is reading key/value pairs into the
variables "key" and "value" one after another.
Putting the pair in the table is as simple as:
x[[key]] <- value
Later, retrieving a value from a key would be:
Are there any books that explain how to use the base packages in R or S to
do tasks like this? I feel like I am really stumbling around in the dark
trying to slowly figure things out in R.
When writing a java program to perform some new type of analysis, I
typically lay out a few obvious classes based on the sorts of data I am
trying to extract and start filling in the details of the classes. Is this
the right way to think of programming in R/S?
It occurs to me that some simple java programs and their corresponding R
implementations would be a very powerful form of documentation for java
programmers wanting to learn R. This is my second attempt to come to grips
with R; I tried and failed about a year ago.
Perhaps this forum would be an excellent place to develop such example
program translations? I would certainly be willing to boil down some of my
typical java data analysis programs into short, clear examples, if anyone
would be interested in helping me translate them into R.
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