R package ggplot2

18 views
Skip to first unread message

Robert Beezer

unread,
May 31, 2022, 12:35:56 PM5/31/22
to sage-cell
Hellping a colleague with R in a Sage Cell, so I've chosen R as the language and used the main site for the Sage Cell.  i don't know R very well and she doesn't know Sage very well.  ;-)

Code:

age <- c(25, 30, 56)
gender <- c("male", "female", "male")
weight <- c(160, 110, 220)
mydata <- data.frame(age,gender,weight)
ggplot(mydata, aes(age,weight))+ geom_point()

yields a traceback that ends in

RRuntimeError: Error in ggplot(mydata, aes(age, weight)) : could not find function "ggplot"

I understood that the "ggplot2" library was pre-installed.


Can anybody see what I've got wrong?

Thanks,
Rob

Andrey Novoseltsev

unread,
May 31, 2022, 1:38:58 PM5/31/22
to sage-cell
Has anybody ever used any extra packages for R installed in SageMathCell? I've tried to figure out how to use them and it seems that non of them are actually installed at the moment. Not sure if something has changed recently and they are not actually installed anymore or maybe something is off with permissions.

William Stein

unread,
May 31, 2022, 1:41:14 PM5/31/22
to Robert Beezer, sage-cell
You would also have to load the library you're going to use i.e., put this,

library("ggplot2")

Of course, ggplot2 isn't installed on sage cell server, as Andrey
mentioned. It is installed on cocalc though:

https://cocalc.com/share/public_paths/47a78e5c181266337438c057b4f07e758413c2b5

On Tue, May 31, 2022 at 9:35 AM Robert Beezer
> --
> You received this message because you are subscribed to the Google Groups "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-cell+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cell/49e02a9a-9920-494f-8030-e2f34ae8fc4fn%40googlegroups.com.



--
William (http://wstein.org)

Rob Beezer

unread,
May 31, 2022, 1:50:38 PM5/31/22
to sage...@googlegroups.com


On 5/31/22 10:40, William Stein wrote:
> You would also have to load the library you're going to use i.e., put this,
>
> library("ggplot2")

Thanks, William. We tried the library() function as well, it also throws an error.

William Stein

unread,
May 31, 2022, 1:52:15 PM5/31/22
to beezer, sage-cell
That's because "Of course, ggplot2 isn't installed on sage cell
server, as Andrey mentioned."

>
> --
> You received this message because you are subscribed to the Google Groups "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-cell+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cell/d345bdc8-2392-2295-6378-0028f3db5d1c%40ups.edu.



--
William (http://wstein.org)

Andrey Novoseltsev

unread,
May 31, 2022, 2:02:57 PM5/31/22
to sage-cell
On Tuesday, 31 May 2022 at 11:52:15 UTC-6 wst...@gmail.com wrote:
That's because "Of course, ggplot2 isn't installed on sage cell
server, as Andrey mentioned."


It is supposed to be installed, however, there are commands to do it, but apparently they didn't work this time, which made me wonder if they ever did ;-) I think they used too... I will look closer into it when I get a chance. 

Andrey Novoseltsev

unread,
Jun 1, 2022, 7:04:44 PM6/1/22
to sage-cell
So - it seems that there was some network glitch when I was upgrading to Sage-9.6 and R packages didn't get installed without breaking the build. I couldn't see the actual problem, but each installation command was taking about 3 seconds, while usually it is longer and different for different packages. I've rebuilt the containers and now ggplot2 is working as expected:

If somebody has some tips on how to detect in `r.eval("install.package(...)")` that the package was not actually installed well, feel free to share ;-)

Rob Beezer

unread,
Jun 3, 2022, 2:31:29 PM6/3/22
to sage...@googlegroups.com
Thanks very much, Andrey, for your work on this! Great to see it working. I'll
let my colleague know she can experiment somemore.

On 6/1/22 16:04, Andrey Novoseltsev wrote:
> If somebody has some tips on how to detect in `r.eval("install.package(...)")`
> that the package was not actually installed well, feel free to share ;-)

If we can get more people dependent on R via the Sage Cell, then you will hear
about it quite quickly when it goes missing. ;-)

Thanks again,
Rob

Rob Beezer

unread,
Jun 4, 2022, 7:37:50 PM6/4/22
to sage...@googlegroups.com
Dear Andrey,

Looking good now, try the cell just below this paragraph.

https://pretextbook.org/examples/sample-article/html/section-sage-cells.html#p-24

Might be more likely to see this go missing now... ;-)

Thanks once again,
Rob

Andrey Novoseltsev

unread,
Jun 5, 2022, 3:14:26 PM6/5/22
to beezer, sage-cell
Thank you! By the way, there is a comment on that page
(The linking seems a bit buggy, as it repeats the boxplot in the output, as of 2016-06-13).
and it didn't show the extra plot for me now ;-)

--
You received this message because you are subscribed to the Google Groups "sage-cell" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-cell+...@googlegroups.com.

Rob Beezer

unread,
Jun 6, 2022, 3:20:27 PM6/6/22
to sage...@googlegroups.com
Thanks, Andrey. Comment removed, and it'll go live in the next day or two.

Rob
> <mailto:sage-cell%2Bunsu...@googlegroups.com>.
> <https://groups.google.com/d/msgid/sage-cell/a936208f-511f-a3c2-a192-ed33a16b44aa%40ups.edu>.
>
> --
> You received this message because you are subscribed to a topic in the Google
> Groups "sage-cell" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sage-cell/ZRS8ys3bZA0/unsubscribe
> <https://groups.google.com/d/topic/sage-cell/ZRS8ys3bZA0/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to
> sage-cell+...@googlegroups.com
> <mailto:sage-cell+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cell/CAD0_dC4zChWQfxCY5kD04Rge%2BmJUKXgyguXs3Cp7hd0UBV-Lzg%40mail.gmail.com
> <https://groups.google.com/d/msgid/sage-cell/CAD0_dC4zChWQfxCY5kD04Rge%2BmJUKXgyguXs3Cp7hd0UBV-Lzg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages