Unable to print a jpeg plot in r

Viewed 23

My example dataframe looks like this:

dput(t2_example)
structure(list(rDate = structure(c(1651086000, 1651087800, 1651089600, 
1651091400, 1651093200, 1651095000, 1651096800, 1651098600, 1651100400, 
1651102200, 1651104000, 1651105800, 1651107600, 1651109400, 1651111200, 
1651113000, 1651114800, 1651116600, 1651118400, 1651120200, 1651122000, 
1651123800, 1651125600, 1651127400, 1651129200), class = c("POSIXct", 
"POSIXt"), tzone = "UTC"), BattV_Min = c(13.97, 13.58, 13.4, 
13.25, 13.13, 13.04, 12.99, 12.97, 12.96, 12.94, 12.94, 12.93, 
12.93, 12.92, 12.91, 12.9, 12.89, 12.89, 12.87, 12.86, 12.85, 
12.82, 12.82, 12.83, 13.02)), row.names = c(NA, -25L), class = "data.frame")

Basically, I have 2 columns, 1st with the dates in POSIXct format and the 2nd with several numbers representing the battery voltage. I want to create a jpeg plot (voltage difference through time) with specific dimensions and characteristics and save it directly in a folder.

I trying this:

Sys.setenv(tz='GMT')

mypath= "C:/Users/local/Desktop/t2_plots/bat.jpg"
jpeg(file = mypath, width = 800)
bat<-plot(t2_example$rDate, t2_example$BattV_Min, ylim=c(10,15),pch=".")
abline(h=11, col="red")
print(bat)*

On * the print in NULL

There is a jpeg image that goes to the mentioned folder but the image is empty. I've been searching for what possible I'm doing wrong but I don't know.

Any help will be much appreciated.

0 Answers
Related