当我执行以下代码时:
merged <- interrogations %>%
filter(person=='accused') %>%
count(caseId)
我收到错误:
#Error in count(., caseId) : object 'caseId' not found
但是,当我使用interrogations$caseId
查找时,变量interrogations$caseId
确实存在。我做错了什么?
变量名是德语,但我希望这有助于(审讯= einvernahmen):
structure(list(id = 1:6, person = c("Beschuldigter", "Auskunftsperson",
"Beschuldigter", "Auskunftsperson", "Beschuldigter", "Beschuldigter"
), behoerde = c("Pol", "Pol", "Pol", "Pol", "Pol", "Pol"), datum = c("10.05.2013",
"29.04.2013", "10.05.2013", "06.04.2013", "15.05.2013", "10.05.2013"
), anwBesch = c("ja", "nein", "ja", "nein", "ja", "ja"), anwVert = c("ja",
"nein", "ja", "nein", "ja", "ja"), verhalten = structure(c(2L,
NA, 5L, 1L, 4L, 5L), .Label = c("", "Bestreiten", "Geständnis",
"Schweigen", "Teilgeständnis"), class = "factor"), caseId = c(7L,
7L, 7L, 7L, 7L, 7L), user = c(14L, 14L, 14L, 14L, 14L, 14L),
dokuAussage = c("2", "", "2", "1", "2", "2"), dokuAussageAnd = c("",
"", "", "", "", ""), uebersetzer = c("", "", "", "", "",
""), offenEinv = c("", "", "", "", "", "")), .Names = c("id",
"person", "behoerde", "datum", "anwBesch", "anwVert", "verhalten",
"caseId", "user", "dokuAussage", "dokuAussageAnd", "uebersetzer",
"offenEinv"), row.names = c(NA, -6L), class = c("tbl_df", "tbl",
"data.frame"))
答案 0 :(得分:0)
interrogations %>%
filter(person == 'Auskunftsperson') %>%
count(caseId)
# A tibble: 1 x 2
caseId n
<int> <int>
1 7 2
interrogations %>%
group_by(person) %>%
summarise(freq = n())
# A tibble: 2 x 2
person freq
<chr> <int>
1 Auskunftsperson 2
2 Beschuldigter 4