I click on a excel macro button which uses RExcel to execute an R script that generates a matrix
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 0 0 -3 -3 -3 -3 -2
[2,] 0 0 0 0 4 4 4
[3,] 0 0 0 1 2 1 2
[4,] 0 0 0 0 0 0 1
[5,] 0 0 0 0 1 1 1
[6,] 0 0 0 0 1 1 1
[7,] 0 0 0 0 0 0 0
[8,] 0 0 0 0 0 0 0
[9,] 0 0 0 0 0 0 0
[10,] 0 0 0 0 0 0 1
[11,] 0 0 0 0 0 0 1
[12,] 0 1 1 1 1 1 1
[13,] 0 0 0 0 0 0 0
[14,] 0 0 0 0 0 0 0
[15,] 0 0 0 0 0 0 0
[16,] 0 -1 3 3 3 4 3
[17,] 0 1 2 2 2 1 0
[18,] 0 0 0 0 0 0 0
[19,] 0 -1 -2 -2 -2 -1 -1
[20,] 0 -2 -2 -3 -3 -5 -4
[21,] 0 0 0 0 0 0 0
[22,] 0 0 0 0 0 0 0
[23,] 0 1 1 1 1 1 1
[24,] 0 0 1 1 1 0 1
[25,] 0 0 1 1 1 0 1
[26,] 0 0 1 1 1 1 2
[27,] 0 0 0 0 0 0 1
[28,] 0 0 0 0 0 0 0
[29,] 0 0 0 0 0 0 0
[30,] 0 0 0 0 0 0 0
[31,] 0 0 0 0 0 0 0
and I change this to a data.frame. set a browser() right before
ggplot(melt(graphPrep),aes(value,fill=variable)) + geom_histogram(position = "dodge",binwidth = 1/(buckWidth-1)) + scale_x_continuous(breaks = min(graphPrep):max(graphPrep))
you can use 5 for buckWidth, and breaks -5:5 if you're replicating
then put that line into R, hit enter, and it makes a nice plot. However, if I just press "n" a couple times to try to execute that line (or remove the browser entirely), the graph never shows up.
I'd like to make this completely executable from excel, but as-is I'm defining
drawIt <- function()
{
ggplot(melt(graphPrep),aes(value,fill=variable)) + geom_histogram(position = "dodge",binwidth = 1/(buckWidth-1)) + scale_x_continuous(breaks = min(graphPrep):max(graphPrep))
}
and making the user "drawIt()" in the r console. I'd like to just have this work in excel...