If you use table before putting your data into chisq.test
you should be fine
# Create some fake 'raw' data
dat <- data.frame(gender = sample(c("M","F"), 100,rep = T), ans = as.logical(rbinom(100,1,.3)))
head(dat)
# just use table to get the data into the form needed
chisq.test(table(dat))