plot function not working

Why isn't the plot function working? Nothing happens. I'm not getting an error.

install.packages("plotly")
library(plotly)

rainfall <- c(799,1174.8,865.1,1334.6,635.4,918.5,685.5,998.6,784.2,985,882.8,1071)

rainfall.timeseries <- ts(rainfall,start = c(2012,1),frequency = 12)

print(rainfall.timeseries)

png(file = "rainfall.png")

plot(rainfall.timeseries)

You are trying to write the current plot image out to a png before there is an image. Try putting the png function after the plot().

rainfall <- c(799,1174.8,865.1,1334.6,635.4,918.5,685.5,998.6,784.2,985,882.8,1071)

rainfall.timeseries <- ts(rainfall,start = c(2012,1),frequency = 12)

print(rainfall.timeseries)
#>         Jan    Feb    Mar    Apr    May    Jun    Jul    Aug    Sep    Oct
#> 2012  799.0 1174.8  865.1 1334.6  635.4  918.5  685.5  998.6  784.2  985.0
#>         Nov    Dec
#> 2012  882.8 1071.0

plot(rainfall.timeseries)


png(file = "rainfall.png")

Created on 2019-09-17 by the reprex package (v0.2.1)

1 Like

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