我在Spotfire中使用R脚本来绘制地球化学数据的等高线图,如下所述。
我想做的是使用户能够从表标题的下拉列表中更改interp函数中的z = SiO2,以更改元素,例如z = Al 2 O 3。我已经在文本区域中创建了表头的下拉列表,并创建了一个文档属性作为该下拉列表中脚本的输入。我不知道的是如何将该输入参数传递到R脚本的语法。
感谢任何想法
library(RinR)
library (reshape2)
library (akima)
library (ggrepel)
library (rgdal)
fld <- with(ECave, interp(x = Longitude, y = Latitude, z = SiO2 ))
df <- melt(fld$z, na.rm = TRUE)
names(df) <- c("x", "y", "element")
df$Lon <- fld$x[df$x]
df$Lat <- fld$y[df$y]
DenMapSq <- RGraph(print
(
ggplot(data = df, aes(x = Lon, y = Lat, z = element)) +
geom_tile(aes(fill = element)) +
geom_point(aes ( x = Longitude, y = Latitude), data = ECave, inherit.aes = FALSE)+
geom_text_repel(data = ECave,mapping=aes(x=Longitude, y=Latitude,label=ECave$Well),
size=2.5, box.padding = unit(0.5, "lines"), inherit.aes = FALSE)+
stat_contour() +
ggtitle("element map") +
xlab("Longitude") +
ylab("Latitude") +
scale_fill_continuous(name = "element (%)",
type = 'viridis') +
theme(plot.title = element_text(size = 25, face = "bold"),
legend.title = element_text(size = 15),
axis.text = element_text(size = 15),
axis.title.x = element_text(size = 20, vjust = -0.5),
axis.title.y = element_text(size = 20, vjust = 0.2),
legend.text = element_text(size = 10))
),
packages=c('ggrepel','akima','reshape2','ggplot2'),data=c('fld','df','ECave')
)