如何使用新数据通过R更新postgresql数据库中的数据?
我试过了
dbGetQuery(con,"UPDATE table SET column1=:1,column2=:2, column3=:3
where id=:4", data=Rdata[,c("column1", "column3", "column3","id")])
Run Code Online (Sandbox Code Playgroud)
我也试过用$替换冒号,但这也没用.我一直在:
Error in postgresqlExecStatement(conn, statement, ...) :
unused argument(s)
Run Code Online (Sandbox Code Playgroud) 在data.frame中,我在表单中有一个日期时间戳:
head(x$time)
[1] "Thu Oct 11 22:18:02 2012" "Thu Oct 11 22:50:15 2012" "Thu Oct 11 22:54:17 2012"
[4] "Thu Oct 11 22:43:13 2012" "Thu Oct 11 22:41:18 2012" "Thu Oct 11 22:15:19 2012"
Run Code Online (Sandbox Code Playgroud)
每当我尝试将它转换为as.Date,lubridate或动物园时,我都会得到NAs或错误.
将此时间转换为可读形式的方法是什么?
我试过了:
Time<-strptime(x$time,format="&m/%d/%Y %H:$M")
x$minute<-parse_date_time(x$time)
x$minute<-mdy(x$time)
x$minute<-as.Date(x$time,"%m/%d/%Y %H:%M:%S")
x$minute<-as.time(x$time)
x$minute<-as.POSIXct(x$time,format="%H:%M")
x$minute<-minute(x$time)
Run Code Online (Sandbox Code Playgroud) 你如何根据因子变量水平的观察数量进行子集化?我有一个包含1,000,000行和近3000个级别的数据集,我想用更少的200个观察值来对这些级别进行分组.
data <- read.csv("~/Dropbox/Shared/data.csv", sep=";")
summary(as.factor(data$factor)
10001 10002 10003 10004 10005 10006 10007 10009 10010 10011 10012 10013 10014 10016 10017 10018 10019 10020
414 741 2202 205 159 591 194 678 581 774 778 738 1133 997 381 157 522 6
10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038
398 416 1236 797 943 386 446 542 508 309 452 482 425 272 261 291 145 598
10039 10040 …Run Code Online (Sandbox Code Playgroud)