【发布时间】:2021-06-27 15:10:06
【问题描述】:
我在整个代码中都使用了过滤器,但这个实例不起作用。我不知道为什么。
{sql Graduation, eval=FALSE, connection=con, include=FALSE, output.var= "AY1519_Grads"}
SELECT *
FROM dm_prd_cers_student_completion
WHERE Year_Grad BETWEEN '2015' AND '2019'
AND txt_program_code IN ('480501', '480508','150702')
AND txt_oe_indicator= 'OPEN'
{r GradbyYear.MachineTools, echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE}
library(tidyverse)
library(kableExtra)
library(dplyr)
Mech_tool_grad <- AY1519_Grads %>%
filter(txt_program_code == "480501") %>%
group_by(txt_college_name, txt_degree_level_name, Year_Grad) %>%
summarise(Count=n(), .groups= "drop") %>%
pivot_wider(names_from=c(Year_Grad, txt_degree_level_name), values_from= Count, values_fill=0) %>%
relocate(txt_college_name, `2015_Certificate < one year`, `2015_One year but < two year certificate`,`2015_Associate I creditable`, `2016_Certificate < one year`, `2016_One year but < two year certificate`,`2016_Associate I creditable`,`2017_Certificate < one year`, `2017_One year but < two year certificate`,`2017_Associate I creditable`,`2018_Certificate < one year`, `2018_One year but < two year certificate`, `2018_Associate I creditable`,`2019_Certificate < one year`, `2019_One year but < two year certificate`, `2019_Associate I creditable`)
kable(Mech_tool_grad, "latex", booktabs=T, align= "lccccccccccccccc", col.names= c("College", "Certificate", "Diploma","Associate's Degree", "Certificate", "Diploma", "Associate's Degree","Certificate", "Diploma", "Associate's Degree","Certificate", "Diploma","Associate's Degree", "Certificate", "Diploma","Associate's Degree"), caption= "\\textbf{Table 1} \\textit{Enrollment by year and Degree Level for Machine Tool Tech Majors}", row.names= F, escape=F) %>%
kable_styling(latex_options = c("hold_position", "scale_down"), position = "left") %>%
row_spec(0, align = "c") %>%
add_header_above(c(" "=1, "AY15-16"=3, "AY16-17"=3, "AY17-18"= 3, "AY18-19"=3, "AY19-20"= 3)) %>%
add_footnote(.,c("CERS Enrollment Table","Date Retreived: 3/29/2021"), notation= "symbol", escape=F)
这是错误
过滤器错误(., txt_program_code == "480501") : object 'AY1519_Grads' not found 调用:
【问题讨论】:
标签: r filter dplyr r-markdown