Problem running datasets in Rstudio

I am an new Rstudio user and I have a strange problem with running datasets: I was able to easily import my dataset, but whenever I try to run it, it just doesn't work. When I start typing the name of the dataset a list opens for me to select it, and after I select and run it, a line with the name of the dataset (in blue) appears in the console, so it looks like something is happening, but the dataset itself doesn't appear and I can't work with it. I've tried datasets such as iris and mtcars, and the exact same thing happens there too. However, strangely enough I am able to run iris3 without any issues.

This is how I ran sample datasets:

mtcars
df <- dplyr::starwars
df
iris3
iris

I've tried updating Rstudtio, uninstalling and re-installing, restarting the program &computer, and still- the only dataset I can successfully run is iris3.

Any ideas on why my Rstudio is being so selective?

Thanks!

Two questions for you:

  1. What happens when you run
data()

in the console?

  1. When you say you try to run a data set, what exactly are you doing? Are you trying to print it by entering the data set name in the console?

Try running a command in the console like

head(mtcars)

You should see the first few rows of the data set printed in the console

Hey, thanks for replying! Yes, I've been entering the data set name in the console and then running it.
After reading your response I tried running the following:

data("iris")
data("mtcars")

head(mtcars)

I got the same result as before- nothing appears for neither of the commands. Once I run the command, a space appears underneath the chunk (where the data set should appear) but it's empty.

By using the word "chunk", you give me the impression you are not entering the commands in the console but in the scripts (might not be the official term) area. The console is at the lower left, unless you have changed the layout, and there is a prompt to the left of every command. The prompt is probably >.

You can use the menu View -> Panes to manipulate the pane layout.

By the way, you can run commands in the script area using CTRL + Enter

Yes, I am entering the commands in the scripts and not the console. Whenever I run a command in the scripts, it pops up in the console too in blue, but does not actually pull up my data set (or any other data set other then iris3 for that matter).

I've also tried running the commands in the console now, using CTRL+ENTER, like you suggested. Unfortunately I had no luck with that either, it's not working..

Could you post a screenshot of your RStudio session?

Sure, here is a screenshot after I tried to run many commands on a few different data sets. Again, the only one that produced some kind of output was when I used iris3

Thanks!

I can see in your screen shot that df, iris, and Suicideonline17_full_1_ are loaded. This is at the upper right in the Environment tab. mtcars is also available as a Promise, which is a fancy way to say that it is available but has not been called for yet.
In the console, at the lower left, you should be able to enter

sum(iris$Sepal.Length)

and get the response

[1] 876.5

Console commands are ended with a plain Enter.

Thanks, that actually works both in the console and in the script window. Still, whenever I try using Dplyr commands for example (such as select, mutate, etc.), they only work in the console and not in the script. Any idea how I can fix that? The reason I have RStudio and not R is because I find working with the script window a lot more convenient than the console.

Please make a reproducible example (reprex) of dplyr not working for you. One of the How To posts on making a reprex is here.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.