Any data analysts good with R?

The Homebrew Forum

Help Support The Homebrew Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
I'm sorry i opened my mouth. What is this witchcraft?

Think i'll stick with my object orientation

Yup, R is like a ******* love-child of Matlab and a normal programming language. Almost everything is a vector or matrix, so instead of looping through elements of a list, you do everything in one go. This reaps great performance advantages by exploiting highly optimised numerical algebra routines. Unintuative when you start out, but powerful once you get your head round the indexing syntax.
 
Here:
Code:
keywords <- c("A","B","C","D","E","F","G","H","I","J")
ranks <- c(3,1,5,7,2,8,2,4,9,2)
rank_to_visibility <- c(95,90,80,70,55,45,35,15,0)
visibilities <- rank_to_visibility[ranks]
volumes <- c(1000,200,40000,25000,1250,6000,2000,2000,300,100)
d <- data.frame(keywords,visibilities,volumes,visibilities*volumes)
d[order(-d[,4]), ]

The rank_to_visibility converts the rank into the visibility score. In this toy example there are only 9 ranks, thought I understand you will have 101. Then, we create a new vector, visibilities, which has the same length as the number of keywords, and contains the visibility instead of the rank. The rest is the same:

Code:
> d[order(-d[,4]), ]
   keywords visibilities volumes visibilities...volumes
3         C           55   40000                2200000
4         D           35   25000                 875000
7         G           90    2000                 180000
8         H           70    2000                 140000
5         E           90    1250                 112500
6         F           15    6000                  90000
1         A           80    1000                  80000
2         B           95     200                  19000
10        J           90     100                   9000
9         I            0     300                      0

Thanks, this seems to work on a few trials. I'll try it out on my main spreadsheet.

I definitely need to learn a programming language for dealing with data, as a lot of the datasets I use are too big for Excel to handle. I tried learning Python but found it a bit tricky. Went to R and it sticks a lot easier. I think because it's quite similar to Excel which I have a lot of experience with, and being made specifically for data probably helps as well.
 
Back
Top