3

Has anybody managed to call ggplot functions successfully using RLink?

I've tried the following in Windows 10 with Mathematica 11.3;

In[7]:= Needs@"RLink`"

In[11]:= InstallR["RHomeLocation" -> "C:\Program Files\R\R-3.4.1"]

In[9]:= REvaluate["examData<-read.delim(&quot;C:/Users/robertn/Documents/
Wolfram Mathematica/DSUR/Exam Anxiety.dat&quot;, header = T)"]

Out[9]= RDataFrame[ RNames["Code", "Revise", "Exam", "Anxiety", "Gender"], RData[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103}, {4, 11, 27, 53, 4, 22, 16, 21, 25, 18, 18, 16, 13, 18, 98, 1, 14, 29, 4, 23, 14, 12, 22, 84, 23, 26, 24, 72, 37, 10, 3, 36, 43, 19, 12, 9, 72, 10, 12, 30, 15, 8, 34, 22, 21, 27, 6, 18, 8, 19, 0, 52, 38, 19, 23, 11, 27, 17, 13, 42, 4, 8, 6, 11, 7, 15, 4, 28, 22, 29, 2, 16, 59, 10, 13, 8, 5, 2, 38, 4, 10, 6, 68, 8, 1, 14, 42, 13, 1, 3, 5, 12, 19, 2, 19, 11, 15, 23, 13, 14, 1, 9, 20}, {40, 65, 80, 80, 40, 70, 20, 55, 50, 40, 45, 85, 70, 50, 95, 70, 95, 95, 50, 60, 80, 75, 85, 90, 30, 60, 75, 75, 27, 20, 75, 90, 60, 30, 80, 10, 85, 7, 5, 85, 20, 45, 60, 70, 50, 25, 50, 40, 80, 50, 35, 80, 50, 49, 75, 25, 65, 80, 50, 70, 40, 80, 10, 20, 40, 40, 70, 52, 50, 60, 80, 60, 65, 15, 85, 20, 80, 100, 100, 80, 10, 70, 100, 70, 70, 65, 75, 85, 30, 5, 10, 90, 70, 20, 85, 35, 30, 70, 55, 75, 2, 40, 50}, {86.298, 88.716, 70.178, 61.312, 89.522, 60.506, 81.462, 75.82, 69.372, 82.268, 79.044, 80.656, 70.178, 75.014, 34.714, 95.164, 75.82, 79.044, 91.134, 64.536, 80.656, 77.432, 65.342, 0.056, 71.79, 81.462, 63.73, 27.46, 73.402, 89.522, 89.522, 75.014, 43.58, 82.268, 79.044, 79.044, 37.132, 81.462, 83.074, 50.834, 82.268, 78.238, 72.596, 74.208, 75.82, 70.984, 97.582, 67.76, 75.014, 73.402, 93.552, 58.894, 53.252, 84.686, 89.522, 71.79, 82.268, 69.372, 62.118, 68.566, 93.552, 84.686, 82.268, 81.462, 82.268, 91.134, 91.94, 86.298, 72.596, 63.73, 63.73, 71.79, 57.282, 84.686, 84.686, 77.432, 82.268, 10., 50.834, 87.91, 83.88, 84.686, 20.206, 87.104, 83.88, 67.76, 95.97, 62.118, 84.686, 92.746, 84.686, 83.074, 73.402, 87.91, 71.79, 86.298, 84.686, 75.82, 70.984, 78.238, 82.268, 79.044, 91.134}, RFactor[{2, 1, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1}, RFactorLevels["Female", "Male"]]], RRowNames[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103]]

In[13]:= REvaluate@"install.packages(&quot;ggplot2&quot;)"

In[15]:= REvaluate@"library(ggplot2)"

This last step is where it falls down. (The penultimate expression manages to bring up a dialog on which mirror to download the package from and then installation begins, including what I assume are dependencies.) The message I get on executing the last expression is;

REvaluate::rerr: Failed to retrieve the value for variable or piece of code library(ggplot2). 
The following R error was encountered: 
Error in library(ggplot2) : there is no package called 'ggplot2'

thanks

RobertNathaniel
  • 790
  • 4
  • 12

0 Answers0