I want to create a shiny app for the pls-sem analysis, I'm trying to achieve my goal by using the package sortable. I need a list that changes with the user's input then I have to implement a drag and drop function to permit user to select every manifest variables and every latent variables and an action button to make the user choose the number of latent variables.
For the creation of app I was inspired by jamovi.
Here is the menu I want to recreate:
I could create an interface to let the user insert the dataset but I couldn't develop the rest. This is my code for now:
library(shiny)
library(DT)
library(readr)
library(shinythemes)
library(shinydashboard)
library(sortable)
exampledataset <- data.frame(A = runif(n=4, min=1, max=6),B = runif(n=4, min=1, max=6),C = runif(n=4, min=1, max=6))
ui <- dashboardPage(
dashboardHeader(title = "ShinySem"),
dashboardSidebar(
sidebarMenu(
menuItem("Insert data", tabName = "data"),
menuItem("Choosing variables", tabName = "drag")
)
),
dashboardBody(
tabItems(
tabItem(tabName = "data",
fileInput("infile","Insert your dataset in csv",accept = c(".csv","text/csv","text/comma-separated-values")),
radioButtons("separator","Separator: ",choices = c(";",",",":"), selected=";",inline=TRUE),
dataTableOutput("userfile")),
tabItem(tabName = "drag",
uiOutput("bucket"))
)
)
)
server <- function(input,output,session){
#Rendering data
df_uploads <- reactive({
data <- input$infile
if (is.null(data))
return(exampledataset)
df <- read.csv(data$datapath, header = TRUE,sep = input$separator)
return(df)
})
output$userfile<- renderDataTable({
df <- df_uploads()
datatable(df)
})
#Render Bucket list and drag and drop
output$bucket <- renderUI(
bucket_list(
header = "Drag and drop",
group_name = "bucketlistgroup",
orientation = "horizontal",
add_rank_list(
text = "dataset you have insert",
labels = listlabel(),
input_id = "starting_variables"),
add_rank_list(
text = "Latent endogenous variables",
labels = NULL,
input_id = "endogenous"),
add_rank_list(
text = "Latent Exogenous variables",
labels = NULL,
input_id = "expgenous"))
)
#Reactive label
listlabel <- reactive({
label <- colnames(df_uploads)
label
})
}
shinyApp(ui, server)
Please let me know if this is possible and how I can achieve it.
