インポートされた日付の選択されたカラムタイプを変更したいと思います。操作は、光沢のあるアプリで行う必要があります。データはCSV fileにあります。このデータセットでは、変更する必要のある列を「日付」と呼びますが、変更する列の名前を入力することが理想的です。インポートされたデータセットのカラムタイプを光沢で変更してください
私が書いたコード:それは、次のエラーが発生し
ui <- fluidPage(
titlePanel("Test"),
mainPanel(
fluidRow(
column(5,
fileInput('file1', "Input a csv file:"),
accept=c('text/csv',
'text/comma-separated-values,text/plain',
'.csv'),
checkboxInput('header', 'Header', TRUE)),
column(3,
radioButtons('sep', 'Separator',
c(Comma=',',
Semicolon=';',
Tab='\t'),
',')
),
column(3,
radioButtons('quote', 'Quote',
c(None='',
'Double Quote'='"',
'Single Quote'="'"),
'"')
)
),
tableOutput("first.two"),
fluidRow(
column(4,
textInput("time.var", h3("Input time variable:"),
value = ""))
),
p(strong("Variables to choose from:"), textOutput("possible.variables")),
p(strong("Classes of variables"), textOutput("variable.classes"))
)
)
server <- function(input, output){
dset.in <- reactive({
infile <- input$file1
if(is.null(infile)){
return(NULL)
}
df <- read.csv(infile$datapath, header = input$header,
sep = input$sep,quote = input$quote)
return(df)}
)
# Change column type to date
# When three lines below are commented out, the code works
dset.in()$date.input <- observeEvent({
dset.in()[,input$time.var] <- lubridate::date_decimal(dset.in()[,input$time.var])
})
output$first.two <- renderTable({head(dset.in(), 2)})
output$possible.variables <- renderText(
names(dset.in())
)
output$variable.classes <- renderText(
sapply(dset.in(), class)
)
}
shinyApp(ui = ui, server = server)
:
Warning in if (!is.na(attribValue)) { :
the condition has length > 1 and only the first element will be used
Warning in charToRaw(enc2utf8(text)) :
argument should be a character vector of length 1
all but the first element will be ignored
Warning in body(fun) : argument is not a function
Warning: Error in eval: argument "expr" is missing, with no default
Stack trace (innermost first):
44: eval
43: makeFunction
42: exprToFunction
41: observeEvent
40: server [#16]
4:
3: do.call
2: print.shiny.appobj
1:
Error in eval(call("function", args, body), env) :
argument "expr" is missing, with no default