Graphs not showing when plotting in R


#1

Hello
I am getting started to R and decided to use code it in atom since I already used it for python and c++.
The problem is, when I try to plot something, it just compiles with no errors but does not display any graph.
I run my scripts with the ‘script’ package and there is no problem with plotting in python this way (a screen pops up with the graph).
In case you think my code is wrong (which, would be completely possible):

data(cars)
plot(cars$speed, cars$dist)

I believe this is not a problem, tho, since I am copying it from a tutorial h3h3
Using fedora 28.
Is there anything I should install or something?
Thanks


#2

Do you see a graph when you run your R code from the command line?


#3

Ehmmm
Can not see any command line in atom.
Is there anything I have to install?


#4

The command line is accessed using a program on your computer, probably called Terminal or similar. There are terminal packages for Atom, but you don’t need one to do what @DamnedScholar asked


#5

Sorry, I assumed that since you were using Linux you would be familiar with your computer’s command line interface. Unfortunately, I have no Fedora experience so I can’t really help with that.

Addendum: And you shouldn’t use an Atom package to test whether the basic CLI functionality works, since it will have the same environment and permissions. There’s no difference between script running python for you and you running it in termination.


#6

Oh man, I am dumb, I thought you mean a command line in the atom program like it is in Rstudio.
It does NOT graph anything if I run it via de command line using Rscript either.


#7

That indicates that there is a problem with your script. It’s possible that RStudio is doing some things by itself, like how Python notebooks will print the last variable in the block; normally, you’d need to call the show method (in Python matplotlib) on a plot to actually open it.

It may help to read the docs of the plot function, to see what it’s supposed to do.


#8

I don’t know any R, but I can definitively tell you that if you figure out how to conjure a graph from your system shell, you can do it from Atom with just a little configuration at the worst. If R doesn’t make that feature accessible from the command line, then implementing it in Atom would require someone familiar with the language and an open-source library that can be hooked into JavaScript.