I'm working with RMarkdown for the first time. I have some R code that uses Tidyverse tools to group, aggregate and shape some data that I want to then chart and annotate in RMarkdown. The code works in a standalone R file, but when I bring it into RMarkdown it fails on the first statement after I bring in the data from a CSV. It seems like it doesn't like the some of the tidy syntax or maybe the %IN%
operator. Not sure what's going on, but I can't seem to get the code to work in Markdown. Curious if somebody can help me get over this hurdle.
Code snippet below....
---
title: "Outbound US Border Crossing Analysis"
author: "Marc Alexander"
date: "`r Sys.Date()`"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
library(tidyr)
library(lubridate)
library(tidyverse)
library(scales)
## Get content into a data frame
## data <- read.csv("~/R/2024-04 Learning Effort/_input/Border_Crossing_Entry_Data.csv",
## header = TRUE, sep = ",")
## print(data)
filter(read.csv("~/R/2024-04 Learning Effort/_input/Border_Crossing_Entry_Data.csv",
header = TRUE, sep = ",")
, Measure %in% c("Personal Vehicles","Personal Vehicle Passengers", "Pedestrians"))