我想使用 RMySQL 包来查询数据库。我通常在使用R 脚本之前ssh website.com在我的 mac 终端中输入。dbConnect()dbGetQuery()
我的数据库位于防火墙后面,只能在本地访问,据我所知,需要通过 ssh 进入。
整个过程可以用R来完成吗?
我尝试过system('ssh website.com'))但没有成功
谢谢
我正在尝试将列表转换为向量,以便我可以将其附加到数据帧,但它会引发错误。取消列表后,它变得更短,我不知道为什么。
谢谢,非常感谢任何帮助。
> mongo_jr$last_state <- unlist(last_state)
Error in `$<-.data.frame`(`*tmp*`, "last_state", value = c("created", :
replacement has 203819 rows, data has 203823
> str(last_state)
List of 203823
x <- unlist(last_state)
> str(x)
chr [1:203819] "created" "created" "created" "created" "created" "created" "created" "created" ...
Run Code Online (Sandbox Code Playgroud) 我有下面的数据集,我想整理一下.
user_id topic may june july august september october
1 192775 talk 2 0 0 2 2 1
2 192775 walk 165 123 128 146 113 105
3 192775 bark 0 0 0 0 0 0
4 192775 harp 0 0 0 0 0 1
Run Code Online (Sandbox Code Playgroud)
我想用tidyr塑造成下面的格式.
user_id month talk walk bark harp
192775 may 2 165 0 0
192775 june 0 123 0 0
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏
我有一个以下格式的数据框,我试图找到事件'分配'和上一次事件'创建'之前的时间差异.
**AccountID** **TIME** **EVENT**
1 2016-11-08T01:54:15.000Z CREATED
1 2016-11-09T01:54:15.000Z ASSIGNED
1 2016-11-10T01:54:15.000Z CREATED
1 2016-11-11T01:54:15.000Z CALLED
1 2016-11-12T01:54:15.000Z ASSIGNED
1 2016-11-12T01:54:15.000Z SLEEP
Run Code Online (Sandbox Code Playgroud)
目前我的代码如下,我的难点是在ASSIGNED事件之前选择CREATED
test <- timetable.filter %>%
group_by(AccountID) %>%
mutate(timeToAssign = ifelse(EVENT == 'ASSIGNED',
interval(ymd_hms(TIME), max(ymd_hms(TIME[EVENT == 'CREATED']))) %/% hours(1), NA))
Run Code Online (Sandbox Code Playgroud)
我正在寻找输出
**AccountID** **TIME** **EVENT** **timeToAssign**
1 2016-11-08T01:54:15.000Z CREATED NA
1 2016-11-09T01:54:15.000Z ASSIGNED 12
1 2016-11-10T01:54:15.000Z CREATED NA
1 2016-11-11T01:54:15.000Z CALLED NA
1 2016-11-12T01:54:15.000Z ASSIGNED 24
1 2016-11-12T01:54:15.000Z SLEEP NA
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 httr 从在线来源导入一个 csv,一切都很好,除了它读取一列作为整数时它应该是双精度导致这些值显示为 NA
我正在使用并遇到以下问题。
getdata <- GET(paste("https://rest.zuora.com/v1/files/",r$FileId, sep = ''), auth)
invoice <- content(getdata, type = "text/csv")
Parsed with column specification:
cols(
Account.external_id__c = col_integer(),
Invoice.Amount = col_double(),
Invoice.Balance = col_integer(),
Invoice.CreatedDate = col_datetime(format = "")
)
Warning: 171 parsing failures.
row col expected actual
2475 Invoice.Balance no trailing characters .4
2726 Invoice.Balance no trailing characters .71
3197 Invoice.Balance no trailing characters .3
3287 Invoice.Balance no trailing characters .5
3350 Invoice.Balance no trailing characters .1
.... ............... ...................... …Run Code Online (Sandbox Code Playgroud)