Doing More with R

17 Nov

I was reading the following post by a guy who really doesn’t like brackets, and as someone who usually programs in F#, he has introduced F#-like functions into R to avoid them:

I’m not so worried about how many brackets I have to endure in my life, but I would like R to do things that I can do in other platforms. For example, I would like R to do more of what I can do in SQL.

A lot of the data I work with is already in an SQL Server database, so it makes sense, seeing as SQL is fairly straight forward to use, to do a considerable amount of data processing there, before exporting a .CSV to R.

More recently, I have been given .csv’s to play with outside of the normal database, but with the job of joining them to tables within the database before analysing in R. My default has been to upload these new files into SQL Server, do all my joins, make a new .csv and upload into R for analysis. Which is still fine, but if the balance moves towards more tables provided as .csvs, less as pre-existing tables in SQL Server, it’s time to figure out how to join the table in R.

And there is a way to join the tables in R that is very simple, and that I found after a five second search on Stack Exchange ( where I have never needed to post a question to find an answer -someone always has already done that for me) :

The conclusion from the answer: the ‘merge’ command will do the job, and the syntax is in many ways easier to follow than the SQL syntax!



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: