【问题标题】:i wanted to make the csv file as a database in R programming我想将 csv 文件作为 R 编程中的数据库
【发布时间】:2018-01-17 03:12:56
【问题描述】:

我希望我的 csv 文件作为一个数据库,用于存储我在运行程序时输入的数据。它应该继续添加名称

add_prob<-function()
ad<-as.integer(readline("Enter how many probables, you are going to add: 
"))
df=data.frame(Reg=NA,Na=NA,Do=NA,Co=NA,E=NA)
for (i in 1:ad) {
dt<-Sys.Date()
Reg<-format(dt,format="%d %B % %Y")
Na<-readline("Enter the participant Name: ")
Do<-readline("Enter the domain he is working: ")
Co<-readline("Enter his mobile number: ")
E<-readline("Enter his E-mail ID: ")
df<-rbind(df,data.frame(Reg,Na,Do,Co,E))
}
write.csv(df, file="Training_Probables.csv", append=TRUE, row.names = 
FALSE, quote = TRUE)
df=df[-1,]
names(df)=c("Date","Name","Domain","Mobile No.", "E-Mail ID")
print(df)
write.csv(df, file="Training_Probables.csv", append=TRUE, row.names = 
FALSE, quote = TRUE)

【问题讨论】:

  • 你想从命令行运行它,即打开一个终端并像Rscript add_user_todb.r 'John' 'IT' '000-111-222' 'john@it.com' 那样做某事并让r脚本自动将此条目附加到数据库吗?

标签: r database csv


【解决方案1】:
write.table(myDF, "myDF.csv", sep = ",", col.names = T, append = T)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-14
    • 2020-02-22
    • 1970-01-01
    • 2016-10-31
    • 1970-01-01
    • 1970-01-01
    • 2019-04-06
    相关资源
    最近更新 更多