Doesn't plot automatic!!!!!!

HELP ? WHY DID THIS CODE GIVE NOT AUTOMATICLY A PLOT?
I'm using R-studio version Version 1.2.5019 on windows 10 home edition:

library(dplyr)
library(datasets)

Pollution <- readRDS("summarySCC_PM25.rds")
types_of_combustion <- readRDS("Source_Classification_Code.rds")

Pollutiongrp <-group_by(Pollution, year) ##grouping the pollution by year

Pollution_all <- summarise(Pollutiongrp, emmisions_year= sum(Emissions)) ## calculates the mean per year over all regions

## plot a graph with base in R and output png
# 1. Open jpeg file
png(file = "Plot1.png")

with(Pollution_all,plot(year,emmisions_year, main= "group pollution by year over all US",xlab = "Year", ylab = "total PM2.5 emission [tons]"))

## Copy my plot to a PNG file
** dev.copy(png, file = "Plot1.png")**
** print("Plot1.png")**
## Don't forget to close the PNG device!
** dev.off()**

thx for helping me

If I run the following code I get a file in my working directory containing an image of the plot. Does this work for you?

DF <- data.frame(X=5:8, Y=15:18)
png(file="junk2.png")
with(DF,plot(X,Y))
dev.off()

Thx for the reply, yes it works in my version, but in the plot zone of Rstudio I do not see a plot, but i can open the plot with my filemanager

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