Я новичок в г блестящем.поэтому, пожалуйста, помогите мне, как я могу получить доступ к загруженному файлу .csv, чтобы сделать выбор функции.потому что теперь я делаю выбор функции, импортируя набор данных в среду r studio
Я пробовал на r studio и rshiny app
# Sidebar layout with input and output definitions -enter code here sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
#tags$ol(
#tags$li("Chi-Square Filter"),
# ),
#strong('FEATURE SELECTION'),
#br(),
#br(),
#actionButton("goButton2", "1. Feature Selection using Random forest"),
#br(),
#br(),
#actionButton("goButton4", "2. Feature Selection using jRip"),
fileInput("dataset", "Choose CSV File",
multiple = TRUE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
#Include clarifying text ----
helpText(em("Note: This app requires file in csv format only!!")),
helpText(em("Note:Select all the inputs and click on button as given below to exectute the app")),
#Input: Checkbox if file has header ----
checkboxInput("header", "Header", TRUE),
#Input: Select separator ----
radioButtons("sep", "Separator",
choices = c(Tab = ",",
comma = "\t"),
selected = ","),
selectInput("select", "Select columns to display", names(data), multiple = TRUE),
actionButton("update", "Update DataSet", class ="btn-primary",style='padding:4px; font-size:120%'),
downloadButton("downloadData", "Download")
),
# Main panel for displaying outputs ----
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("ABOUT",br(),p(tags$b("Feature Selection"), "is the process where you automatically or manually select those features which contribute most to your prediction variable or output in which you are interested in. Having irrelevant features in your data can decrease the accuracy of the models and make your model learn based on irrelevant features. Here in this web application we have tried to implement few of the feature selection methods which we have used in our research work.
"),br(),br(),p(tags$b(" Steps to be Followed")),
br(),p("First Click on the 'Output' tab which you want and then click the corresponding action button consisting of different feature selection methods in the side bar layout in order to view the results. The most important attributes of the dataset is displayed.
")),
tabPanel("FEATURE SELECTION", br(),br(),actionButton("goButton2", " Feature Selection using Random forest"), textOutput("diswt2"),br(),br(),actionButton("goButton4", " Feature Selection using mop")),
tabPanel("CLASSIFICATION", textOutput("diswt5")),
tabPanel("DATA",DT::dataTableOutput("mytable")),
tabPanel("AUTHOR", br(),tags$h1("CONTACT US"),br(),br(),p(tags$b("Sachin, Joyal")),br(), p(tags$b("Department of Computer Applications")),br(),
p(tags$b("SNGIST Group of Institutions")),br(),
p(tags$b("N Paravur, Kerala,India")),br(),br(),p(tags$b("email:kavithacr@sngist.org"))))
)
)
)
server:
library(shiny)
shinyServer(function(session,input, output) {
observeEvent(input$goButton2,{
source("randomfrst.R")
output$diswt2<-renderPrint(wts2())})
observeEvent(input$goButton4,{
source("eg.R")
output$diswt5<-renderPrint(wts5())})
data <- reactive({
req(input$dataset)
read.csv(input$dataset$datapath, header = input$header,sep = input$sep)
})
filtereddata <- eventReactive({
input$update
data()
}, {
req(data())
if(is.null(input$select) || input$select == "")
data() else
data()[, colnames(data()) %in% input$select]
})
observeEvent(data(), {
updateSelectInput(session, "select", choices=colnames(data()))
})
output$mytable <- renderDataTable(filtereddata())
# Downloadable csv of selected dataset ----
output$downloadData <- downloadHandler(
filename = function() {
paste(input$select, ".csv", sep = "")
},
content = function(file) {
write.csv(filtereddata(), file, row.names = FALSE)
}
)
})
функция:
library(mlbench)
library(FSelector)
wts2<-function(){
ds<-sapnew
weights <- random.forest.importance(class~., ds, importance.type = 1)
#print(weights)
subset <- cutoff.k(weights, 5)
f <- as.simple.formula(subset, "class")
return(f)
}