我上传了一个CSV文件,为了使代码标准化,我想更改列名。因此,我使用以下代码:
Prv_mnth_so1 <- reactive({data.frame(lapply(data_uploaded1(),trimws))})
colnames(Prv_mnth_so1()) <- c("GST_ward","Category","order_and_section","combo")
但这会抛出一个错误
警告:<;中出错-:赋值左侧无效(空)
52:服务器[#12]
COLNAMES(PRV_MNTH_SO1())<;-c(";gst_ward";,";Category";,";Order_and_Section";,";order_and_section";,";中的错误:
赋值左侧无效(空)
这意味着我无法在右侧赋值()运算符,但我无法解决此问题
您只能更改reactive
本身内的reactive
的值,因为它基本上是您计算的函数(因此您必须使用方括号)。
您可以1.尝试在创建Prv_mnth_so1
时直接更改它,或者2.稍后在另一个被动上下文中进行更改:
1.
Prv_mnth_so1 <- reactive({
new_table <- data.frame(lapply(data_uploaded1(),trimws))
colnames(new_table) <- c("GST_ward","Category","order_and_section","combo")
new_table
})
Prv_mnth_so1 <- reactive({data.frame(lapply(data_uploaded1(),trimws))})
output$table <- renderTable({
table_data <- Prv_mnth_so1()
colnames(table_data) <- c("GST_ward","Category","order_and_section","combo")
table_data
})