Plotting with ggplot2: List of 9

Hello,

I am just starting out with RStudio and have a general question about plotting with ggplot2.

I am using some sports performance data called quarterone_long. Column headings include Player.Name and Average.Distance. I wish to create a boxplot with Player.Name and Average.Distance as the aesthetics (x and y). I have already subset the data to focus only on one player.

My code reads:

plot <- ggplot(data = quarterone_long, aes(x = Player.Name, y = Average.Distance)) +
  geom_boxplot()

When I run this piece of code, no plot shows. Instead, in the workspace, the plot reads 'List of 9'. Any suggestions as to how I can get my plot to appear will be greatly appreciated.

Thank you.

1 Like

It looks like you need to print your object named 'plot':

print(plot)

Or just type plot if you are doing this interactively.

2 Likes

If you are working on RStudio

You can simply write : plot
plot which in your case is the object to store the ggplot graph and run

It will give you the output under PLots tab.

1 Like