script – What test should I use for comparing two yes/no categories?

I am currently writing a code in R attempting to compare 2 yes/no categories for statistical significance. I used a chi-squared test however am unsure if that is the correct analysis for my data. Here is my existing script:

DATA FRAME =============

file.choose()
pestResponses.df = read.csv(insertpath)

df1 <- data.frame(pestResponses.df(,4),pestResponses.df(,6))
df1

df1$pestResponses.df…4.<-ifelse(df1$pestResponses.df…4.==”yes”,1,2)

df1$pestResponses.df…6.<-ifelse(df1$pestResponses.df…6.==”yes”,1,2)
df1

CHI SQUARE TEST – used to analyze 2 categorical variables ========

chisq.test(df1)

I was unable to get a p-value or x-squared value until I changed the ifelse statement to a 2 instead of a 0. Any advice is appreciated, thank you.