I have a new problem if you don't mind taking a look.
here is my code
library(datasets)
library(tidyr)
library(tibble)
aq.no.missing <- drop_na(mtcars)
options <- c("Cyl" = "Cylinders",
"HP" = "Horsepower",
"qsec" = "1/4 mile time",
"vs" = "Engine")
df.options <- data.frame(options)
df.lv <- rownames_to_column(df.options)
colnames(df.lv) <- c("lable", "value")
ui <- fluidpage(
selectInput("X", "X Variable:",
options),
selectInput("Y", "Y Variable:",
options),
plotOutput("scatter")
)
server <- function(input, output) {
selections<- reactive({
aq.no.missing[, c(input$X, input$Y)]
})
output$scatter <- renderplot({
x_column <- selections()[,1]
y_column <- selections()[,2]
correlation <- cor(x_column, y_column)
regression <- lm(y_column ~ x_column)
intercept <- regression$coefficients[1]
slope <- regression$coefficients[2]
X_Lable <- df.lv$lable[which(df.lv$value == input$X)]
Y_Lable <- df.lv$lable[which(df.lv$value == input$Y)]
plot(x=x_column, y=y_column, xlab = X_Lable, ylab = Y_Lable,
cex.axis = 1.5, cex.lab= 1.5, pch = 20, cex = 2,
main = paste(Y_Lable, "vs", X_Lable,
"\n r =", round(correlation,3),"
Y' =", round(intercept,3), "+", round(slope,3), "X"),
cex.main=1.8)
abline(intercept, slope)
})
}
shinyApp(ui = ui, server = server)
I get an error when the page comes up "unidentified columns selected"
I have messed with the drop downs but nothing.
I don't know exactly what I need to do