Open ndavis4904 opened 2 years ago
try this:
renderPlot({ pairs(d[input$covariates], upper.panel=panel.cor, lower.panel=panel.smooth) })
also, did you insert the chunk from lab 5 prior to the "renderPlot" chunk?
should look something like this:
panel.cor <- function(x, y, digits=2, prefix="", cex.cor) { usr <- par("usr"); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r <- abs(cor(x, y)) txt <- format(c(r, 0.123456789), digits=digits)[1] txt <- paste(prefix, txt, sep="") if(missing(cex.cor)) cex <- 0.8/strwidth(txt)
test <- cor.test(x,y)
# borrowed from printCoefmat
Signif <- symnum(test$p.value, corr = FALSE, na = FALSE,
cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
symbols = c("***", "**", "*", ".", " "))
text(0.5, 0.5, txt, cex = 1.5 )
text(.7, .8, Signif, cex=cex, col=2)
}
panel.smooth <- function (x, y, col = par("col"), bg = NA, pch = par("pch"), cex = 0.5, col.smooth = "red", span = 2/3, iter = 3, ...) { points(x, y, pch = 19, col = gray(0.7,0.2), bg = bg, cex = cex) ok <- is.finite(x) & is.finite(y) if (any(ok)) lines(stats::lowess(x[ok], y[ok], f = span, iter = iter), col = col.smooth, lwd=2, ...) }
jplot <- function( x1, x2, lab1="", lab2="", draw.line=T, ... ) {
plot( x1, x2,
pch=19,
col=gray(0.6, alpha = 0.2),
cex=0.5,
bty = "n",
xlab=lab1,
ylab=lab2, cex.lab=1.5,
... )
if( draw.line==T ){
ok <- is.finite(x1) & is.finite(x2)
lines( lowess(x2[ok]~x1[ok]), col="red", lwd=3 ) }
}
Would I have to save my data as d
earlier in the script?
Actually, I got it figured out. You were right, just using the wrong dataset.
I am having trouble creating the correlation plots under the Drivers of Change section. I put in the following code:
renderPlot({ pairs( pax.sf[ input$covariates ], upper.panel = panel.cor, lower.panel = panel.smooth ) })
But I keep getting the error "non-numeric argument to 'pairs'". Is there anything obvious that is causing the issue @JasonSills ?