The interpolation functions work well but I have encountered some issues with the graphical representations. Ideally, I would like to merge all my plots into one using the par function of the graphics package, which usually works with base R plot.
In my code, "df" is a dataframe containing the coordinates of my points (attributes "X" and "Y") and the value of Aluminium (attribute "Al") and Zinc (attribute "Zn") contaminants measured at each location.
- Code: Select all
```{r, figures-side, fig.show = "hold", out.width = "50%"}
dbAl <- db.create(x1 = as.numeric(df$X),
x2 = as.numeric(df$Y),
z1 = df$Al,
flag.grid = FALSE)
dbZn <- db.create(x1 = as.numeric(df$X),
x2 = as.numeric(df$Y),
z1 = df$Zn,
flag.grid = FALSE)
par(mfrow = c(1, 2))
db.plot(dbAl, title = "Al")
db.plot(dbZn, title = "Zn")
```
When I run this code, the two plots are plotted as two separate graphs and the code returns the error (here, in french):
- Code: Select all
la valeur de 'nc' dans "mfg" est mauvaise et sera ignorée
(meaning "the value of 'nc' in "mfg" is wrong and will be ignored", once translated in English)
So I gather that R has some issue with me trying to set nc =2 in my call of par, especially since the error is not longer raised when I modyfy my code to:
- Code: Select all
```{r, figures-side, fig.show = "hold", out.width = "50%"}
par(mfrow = c(1, 1))
db.plot(dbAl, title = "Al")
db.plot(dbZn, title = "Zn")
```
(which still print the plots as two separate graphes.)
The setting of the chunk allows the output in the knitted file to show the two graphs side-by-side, which is a way to get around the problem if no other solution exist, and was inspired by the answer to a previous question at:
http://rgeostats.free.fr/forum/viewtopic.php?f=20&t=505
But, if possible, I would really like to be able to direcly edit a single graph in which all my plot are combined.
I am very grateful for any attention you might give this question.