• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
21 views

Problem :

I think my dataframe is correct and my code is also okay. But I am facing following error:

Error in .Call.graphics(C_palette2, .Call(C_palette2, NULL)) : invalid graphics state

What is wrong with my below data?

 date   trt var val
1/12/2019    cc  sw5 0.2684138
1/12/2019    cc  sw15    0.2897586
1/12/2019    cc  sw5 0.2822414
2/12/2019    cc  sw5 0.2494583
2/12/2019    cc  sw5 0.2692917
2/12/2019    cc  sw15    0.2619167
2/12/2019    cc  sw5 0.204375
3/12/2019    cc  sw5 0.2430625
3/12/2019    cc  sw5 0.2654375
3/12/2019    cc  sw5 0.2509583
3/12/2019    cc  sw5 0.2055625
1/12/2019    ccw sw15    0.2212414
1/12/2019    ccw sw5 0.3613448
1/12/2019    ccw sw5 0.2607586
2/12/2019    ccw sw5 0.2087917
2/12/2019    ccw sw15    0.3390417
2/12/2019    ccw sw5 0.2436458
2/12/2019    ccw sw5 0.290875
3/12/2019    ccw sw5 0.20175
3/12/2019    ccw sw15    0.328875
3/12/2019    ccw sw5 0.2328958
3/12/2019    ccw sw5 0.2868958

Whenever I want to work with above data, I specify dates like below :

df<-df[order(as.Date(df$date,format="%d/%m/%Y")),,drop=FALSE]

Also I want to make the scatterplot as follows:

ggplot(data = df,aes(x = date,y = val)) + 
 geom_point(aes(group = trt))
by (7.5k points)  
edited by

1 Answer

0 votes

Solution :

I also faced the same error in the past and I managed to fix it by running following code:

dev.off()

and after that running my plot again. I guess my graphics device was messed up earlier also by exporting some graphics I tried but it didn't get reset. But This worked for me.

by (31.9k points)  
...