Error while knitting: Column ____ is unknown

When knitting I get the error line: Quitting from lines 70-96 (218276.Rmd) Error: Column Gender is unknown Execution halted

This is the code between the lines:

### Create any descriptives and/or tables you want to review or include in the report and save each inside an object:
# table_name <- ...table code...
# To make a table appear in a particular place in your report,
# create a code chunk in the corresponding place in this Rmd file
# and put the name of the table object there
# Gender and condition by age

age_desc <- data %>% 
  group_by(Gender, Condition) %>%
    n = n(),
    perc = n()/nrow(data) * 100,
    mean_age = mean(Age),
    sd_age = sd(Age),
    min_age = min(Age),
    max_age = max(Age)

age_desc %>% 
  kable(col.names = c("Gender", "Condition", "N", "%", "Age-Mean", "Age-SD", "Min-Age", "Max-Age"),
        caption = "Table 1: Descriptive statistics by Gender and Condition",
        digits = 2) %>% 
  kable_styling(fixed_thead = T)

The code itself runs and produces the table. There is no typo with gender. I cannot just ignore the error as it will be knitted by a marker with errors enabled. When gender or condition is removed from the code an error is still found with the other column name. I've tried using data$Gender but does not work.

As we cannot reproduce the error on our side because you did not provide a reproducible example, I can just give you hint of possible issues. Please provide a reprex if you want us to help you more easily

When you see some difference between a code running in the R session, and not running when clicking on the Knit button, you should take a look at the environment. You must have in mind that a Rmd when render with the IDE button is knitted in a new clean R session. Sometimes, there could be differences if you have some stuff in your workspace that are not yet reproduced in your Rmarkdown file. For example, if data does not containes Gender, or if a library is not loaded properly.

I could not be that at all but I just was i though reading your issue.

If you can provide more context on the error or a reproducible example, we could help more. Thank you !

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.