使用dplyr - 我无法确定返回已过滤行的行索引的最佳方式,而不是返回已过滤行的内容.
我可以使用dplyr :: filter()从数据帧中提取行...问题是想要提取已过滤行的索引值并将其添加到符合搜索条件的索引条目列表中.
是否有一种简单的方法可以使用dplyr根据特定条件搜索数据帧并返回找到的每一行的数字索引?下面的代码使用r :: which()将索引行提取到列表中......
requiredPackages <- c("dplyr")
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
ipak(requiredPackages)
if (!file.exists("./week3/data")) {
dir.create("./week3/data")
}
# CSV Download
if (!file.exists("./week3/data/americancommunitySurvey.csv")) {
fileUrl <- "https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Fss06hid.csv?accessType=DOWNLOAD"
download.file(fileUrl, destfile = "./week3/data/americancommunitySurvey.csv", method = "curl")
}
housingData <- tbl_df(read.csv("./week3/data/americancommunitySurvey.csv"
, stringsAsFactors = TRUE))
Now we have to extract the relevant data
#
# Create a logical vector …
Run Code Online (Sandbox Code Playgroud) 我想计算R中的时间差(增量时间).时间戳存储在两列数据框中,时间为日期时间(年 - 月 - 日小时:分:秒.msec),例如前三个行:
c_id c_time
6875 2012-08-15 00:00:40.169
6874 2012-08-15 00:01:40.055
6876 2012-08-15 00:02:40.542
Run Code Online (Sandbox Code Playgroud)
我想输出一个有差异的列,例如
c_diff
0
00:01:0.886
00:01:0.487
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我该怎么做?如果您有其他/更好的建议如何保持结果,将非常感谢提前非常感谢!秘书科
请为了上帝的爱,我怎么能让Emacs停止自动填充?我用visual-line-mode
,我不想自动填充.我可以将其关闭,M-x auto-fill-mode RET
但在Noweb模式下,当我进入代码块并再次退出时,它会重新打开.拜托,我只想全球转向自动填充模式,这让我发疯了.
我试过了
(auto-fill-mode 0)
Run Code Online (Sandbox Code Playgroud)
和一堆疯狂的事情一样
(add-hook 'Rnw-mode-hook '(lambda () (auto-fill-mode 0)))
(add-hook 'latex-mode-hook '(lambda () (auto-fill-mode 0)))
Run Code Online (Sandbox Code Playgroud)
但似乎没有任何效果.请帮我.