我正在尝试创建一个反应式页面,其中用户将csv文件作为数据集上传,并根据用户选择的比例将上传的数据集分为训练和验证数据集。分割后,可以选择下载数据集。
我是新的R降价促销。我尝试了多种分割数据集的方法,但是没有任何作用。
library(shiny)
inputPanel(
fileInput("file","Upload the *.csv file with headers")
)
mainPanel(
verbatimTextOutput("AD")
)
AD <- renderPrint({
file1=input$file
if(is.null(file1)){return()}
data = read.table(file = file1$datapath,sep = ",", header = TRUE)
if(is.null(data())){return()}
print(head(data))
})
sidebarPanel(
inputPanel(
sliderInput("slidebar", label = "Enter the proportion of training dataset:",
min = 0, max = 1, value = 1),
numericInput("seed","Enter seed number",value = 1)
)
)
data$spl=sample.split(data,SplitRatio=input$slidebar)
tdata=subset(data,data$spl==TRUE)
vdata=subset(data,data$spl==FALSE)
sidebarPanel(
inputPanel(
downloadButton("download dataset","Download Dataset"),
downloadButton("download training dataset", "Download Training Dataset"),
downloadButton("download validation dataset", "Download Validation Dataset")
)
)
mainPanel(
verbatimTextOutput("BC")
)
BC<-renderPrint({
cat(sprintf("\nThe size of the complete dataset is %f",))
})
当前,我收到“唯一()仅适用于向量”错误。