Get address coordinates with R

I wrote a finction in R which searces for an address given to it as a srting on GoogleMaps, and returns it's latitude and longitude.
Here's the code, which can be found on GitHub too.

IMPORTANT: It needs the rjson package (maybe RJSONIO is ok, too).
getAddressCoord <- function(address){
address <- as.character(address)
address <- paste(unlist(strsplit(address, split=" ")), collapse="+")
base <- "http://maps.googleapis.com/maps/api/geocode/json?address="
ending <- "&sensor=false"
download.file(url=paste(base, address, ending, sep=""),
destfile="temp_address_info.json")
address.info <- fromJSON(file="temp_address_info.json")
unlink("temp_address_info.json")
if(address.info[["status"]] == "OK"){
long.lat <- unlist(address.info$results[[1]]$geometry$location)
return(long.lat)
} else {
return("Result is not appropriate!")
}
}

Warm up is necessary

Even if you are an F1 car. There are lots of videos and articles about how fit the Formula-1 drivers are and how they reach this, which is understandable as the media speaks to broad range of people who are more interested in seeing the wolds best drivers more close to them, see their human face.
Altough there are a lot of people who are more interested in the technical details of this sport, some of them write great blogs with insigths for people like me. I would like to highlight the awesom blog of Craig Scarborough with the most detailed descriptions and drawings of the fresh inventions available for free. In Hungarian, the most tech-fan blog I know is the Formula1Tech written by István Papp. Both ScarbsF1 and Formula1Tech uses Twitter. For these people with a scent of tech-fetish I found a video on Youtube:

It caught my eye immediately, as this is the first video where I can watch what the driver can see on his steering wheel. But this video doesn't only shows, it explains, what we can see, making it more valuable for me. Previously, Sauber published an infographic and a video about steering wheels in F1, but the video did not explain, and the picture did not show it exactly.

Of course, as a good introduction, this explanation of the installation lap creates more questions than I had before. Previously I tought it is only for try some reference settings with a probably good setup. As we can find out, this lap is much more important: this is the first run of the car, this is the lap where the designers, engineers, technicians and the whole team will see what did they create. Sometimes they find big problems, as happened with Lotus last year. But I never knew that the gearbox ha to learn where the ratios are. Also, I tought that engine mapping is somehow a known variable, as it can be tested and set in the garage or in the factoy. Although it's a big question, how can the motor spin the wheels on the ground.
I recommend this video, sadly Mercedes' channel has only a few technical one, and this one stands out from the others.

Lubuntu in da House

Recently I had to use some basic commandline magic both in Windows and on Mac, as I wanted to build a simple application which starts when R start, and closes R when finishes. Well, I couldn't write it properly, but I learnt a lot. However, I decided to try Linux, as I had heard some legends about its small requirements - and if even Windows7 could run on my laptop from the early 2000s, a Linux should be as fast as a lightning. Why did it took a week?
After some googling, I decided to try Lubuntu: in most of the tests it was among the lightest OSs, but (as an Ubuntu-alike) it's user-frendly, which is good for my Windows-formed brain. Of course, things are never so simple like one imagines: my laptop can boot only from CDs and hard drives, and I could not find a writeable empty disc at home. Google was my friend again: downloaded Wubi, and started the procedure.
Problem #1: It could not install Lubuntu. I tried twice, it downloaded the install CD twive, then stopped. As it turned out, it downloads the newer version, checks if it's the one which it knews, and if not (and not, because Wubi is older than the newest Lubuntu), it reports an error.
Problem #2: We tried with Ubuntu, saying we could change the desktop environment later. Well, the Ubuntu 12.04 did not support the old SiS VGA card what my computer has, and nor me, nor my father is a real Linux guru. We spent 1 hour to reinstall Ubuntu, and get the command line. From there, 2 other hours to find the Xorg file we need and try to edit - around half past midnight we stopped trying, except that for one last time I tried something else: the Xubuntu. HEUREKA! It worked, I got enthusiastic, and updated, and upgraded, and installed, and then restarted everything - then the same problem occurred as with Ubuntu. That was the stop for me.
Next day I found a rewritable disc with an old program on it. I formatted the disc and created a Lubuntu 10.04 install disc, which got installed without problem, ran without problem, but it was way too old to cooperate perfectly with the other programs, so I decided to get the 12.04 Lubuntu.
Problem #5: Its CD is bigger than my 650MB RW disc, so I had to find something else. OF course, the hard drive option is still closed as I don't know how to mount a pic to a partition, which is already occupied by the 10.04, DVD! I wrote the DVD as CD, and put it in the reader - which is mine because I rarely use DVD, and it rarely reads a DVD - and this was not one of those rare occasions. This is why I got an old, but stable DVD reader and a few writeable CD-s. With the former, I could read the DVD as CD and started the installation - which happened to become corrupted, I could only see the grub rescue> promt. After it only knew the ls command, and nothing else, I put the Windows CD into the drive and deleted the Lubuntu partitions and get the Windows back to work.
After restarting, I installed the Lubuntu 12.04 from cd, without any problem. And finally, this post is written from the Chromium in Lubuntu 12.04.

First steps in Python

I'm a regular R user. I love R, because it is closer to a programming language than MS Excel, which I had to use before, and closer than SPSS too. In the latter case this only means that R is much more consistent than an SPSS Syntax.

I heard the name of Python a lot, but never tried it, because there were complicated tutorials only. I'm not a programmer, I know nothing about computers. I use Drupal because it is simple, it is not likely that I will write new moduls for it. I can use R, and what's more, about a week ago I wrote my forst S3 object, and maybe I could create a package, but it is still not likely. But then, eventually, how did I start using Python?

Since a few weeks ago I'm a trainee in a firm, and I was told i should learn python, because I will have to understand them. To do this, I got assistance: they halped me install and set the necessary things, obviously at this moment I wouldn't be able to repeat them. But finally, I have an interactive interface for Python, and a useful book to learn it from. I read the first 3-4 chapters and I found these:
- the intendation is important, you cannot use braces for blocks
- the primary prompt contains a space: ">>> "
- if you think about R, every operation is a function. Python has two different "function"-type: some of them don't need braces around arguments, others do.
- there are only one operator for assignment, and it is "="
- you cannot call the last row with the up cursor, although I didn't try page up and page down.

It is interesting for sure, and looks more hardware-close than R, hence it must be faster, I'm curios.

Tags: 

Pages