如何获取变量Ticker等于“ AA”的所有行。数据结构是小标题。我的数据存储在折扣数据中,看起来像
A tibble: 1,048,575 x 7
Date Ticker CUR CON REBATERATE FEERATE AVAILABLE
<chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
1 09/25/2017 A USD 1715006 0.101 1.06 10000000
2 09/25/2017 AA USD 251962528 0.494 0.666 4900000
3 09/25/2017 AAAP USD 212212690 -6.28 7.44 300000
4 09/25/2017 AABA USD 278946664 0.674 0.486 10000000
。 我想获得该行
2 09/25/2017 AA USD 251962528 0.494 0.666 4900000
我尝试了代码:
xx<-filter(rebatedata, Ticker == "AA")
并得到错误:
Error in filter(rebatedata, Ticker == "AA") : object 'Ticker' not found
In addition: Warning messages:
1: In data.matrix(data) : NAs introduced by coercion
2: In data.matrix(data) : NAs introduced by coercion
3: In data.matrix(data) : NAs introduced by coercion.
答案 0 :(得分:2)
如果未加载软件包dplyr
,则会出现此问题。有一个基本R filter
(来自stats
),其行为不同(?stats::filter
)
对单变量时间序列或多变量时间序列的每个序列分别应用线性滤波。
如果我们在全新filter
会话中执行R
,但未加载任何包
filter(iris, Species == 'setosa')
过滤器错误(虹膜,物种==“ setosa”):对象“物种”不存在 找到
或
stats::filter(iris, Species == 'setosa')
stats :: filter(iris,Species ==“ setosa”)中的错误:对象 找不到“物种”
现在,如果我们加载软件包dplyr
library(dplyr)
filter(iris, Species == "setosa")
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#1 5.1 3.5 1.4 0.2 setosa
#2 4.9 3.0 1.4 0.2 setosa
#3 4.7 3.2 1.3 0.2 setosa
#4 4.6 3.1 1.5 0.2 setosa
#...