Hello, I am trying to pass parametrically (in the YAML metadata) the option of filtering a dataset by choosing a specific argument (from YAML "params" ) for the "filter" function.
When I run the code i get an empty table for "my_titanic". When I run the same code in R with this filter --> filter(Class== "parameter1" | Class=="parameter2") works perfectly and I get the filtered "my_titanic" table.
Any idea what am I doing wrong? Any help will be more than welcome.
---
date: "`r Sys.Date()`"
output:
html_document: default
params:
parameter1:
label: 'Parameter 1:'
value: First
input: select
choices:
- 'First'
- 'Second'
- 'Third'
parameter2:
label: 'Parameter 2:'
value: Second
input: select
choices:
- 'First'
- 'Second'
- 'Third'
data:
label: 'Input dataset:'
value: sample.csv
input: file
---
```{r setup, echo=FALSE, message=FALSE}
library(readr)
library(dplyr)
library(ggplot2)
library(datasets)
parameter1 <- params$parameter1
parameter2 <- params$parameter2
dedomena <- params$data
c_Titanic <- read.table(dedomena, sep=",", header=TRUE, stringsAsFactors = FALSE)
my_titanic <- c_Titanic %>% filter(Class== "parameter1" | Class=="parameter2")
```