I love Mathematica, and I would love to be able to use it for all of my data analysis tasks, but there is one type of analysis which I find almost trivial in R, and I have no idea how to approach in Mathematica.
Say I have a CSV file containing a few hundred thousand people's ranked preferences for items, in a format like this:
Gender,X29234,X30310,X28908,...
Male,1,2,3,...
Female,1,3,2,...
...
(in this case the female liked item X28908 more than item X30310)
10000 rows of sample data can be found here.
I want to plot histograms of the ranks each gender assigned to each item. In R I can use reshape2
and ggplot2
to do something like this:
library(reshape2)
library(ggplot2)
merged_data <- read.csv("merged_data.csv")
melted = melt(merged_data, id=1)
ggplot(melted)
+ geom_histogram(aes(x=value,y = ..density..,fill=factor(Gender)),binwidth=1, position="identity",alpha=.5)
+ facet_wrap(~variable)
+ theme(legend.position="bottom")
+ scale_fill_discrete(name="Gender: ")
to get a nice graph like this:
The key thing for me here are that the individual plots all end up having the same axis bounds, even though the bounds of the data in each plot aren't the same, which makes comparisons really easy.
How would I go about doing something like this in Mathematica so I can get rid of R in my workflow?
Edit: I should clarify that this example with Gender is to simplify the problem to something easier to explain, and I'm looking for a solution which is as automatic as possible: doesn't involve enumerating in the source the possible values of the Gender field, doesn't involve hard-coding in the source the bounds of the plot etc. ggplot2 does all of these out of the box, so I'm looking for a reusable approach to do something similar.
merged_data.csv
) that you used for the R plot (or link to it somewhere)? $\endgroup$