【问题标题】:Is there a way to save data as a csv file within plumber codes?有没有办法在管道工代码中将数据保存为 csv 文件?
【发布时间】:2019-10-16 15:47:47
【问题描述】:

我不熟悉使用水管工包和 RESTful API。当我在本地机器上工作时,可以在 @get 函数中添加一行来写入文件夹中的数据文件。当我在虚拟机上托管它时,我似乎无法让它工作。可能是什么问题?

我在下面使用了 write.table(),它在我的本地机器上运行良好。即我能够相应地将数据附加到“data.csv”。在虚拟机上运行脚本的情况下不可能吗?

#* @get /predict_petal_length
get_predict_length <- function(petal_width){
# convert the input to a number
petal_width <- as.numeric(petal_width)
# create the prediction data frame
input_data <- data.frame(Petal.Width=as.numeric(petal_width))
write.table(input_data,"data.csv",append = TRUE,col.names = FALSE)
# create the prediction
predict(model,input_data)
}

【问题讨论】:

    标签: r plumber


    【解决方案1】:

    您可能没有尝试写入的文件夹的写入权限?你的虚拟机配置是什么?

    尝试使用完整路径,使用您确定 R 进程可以在虚拟机上写入的路径。

    而不是“data.csv”、“/tmp/plumber/data.csv”或类似的东西

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-06
    • 2018-09-20
    • 2021-09-23
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多