Error when Kniting to Word but not when I run the chunk code

I am new to R, and am trying to create an Rmarkdown document that knits to word.
When I run the chunk code my data frame, and thus strata sampling and ggplot work just fine. But when I knit to word, it is not working. The issue it states is that the row lengths differ, but I know this is not the case as I checked.

Error in data.frame(Player =, Age = player.age, Age_Group = player.g) :
arguments imply differing number of rows: 9561, 0
Calls: ... withCallingHandlers -> withVisible -> eval -> eval -> data.frame
Execution halted <- P$player
player.age <- P$age
player.g <- P$age_group <- data.frame(
Player =,
Age = player.age,
Age_Group = player.g

[1] 9561
[1] 9561
[1] 9561
[1] 9561

Any insight would be great.


Hi there,
Welcome to the RStudio Community Forum.

To get help with your problem you will need to post a "reproducible example", including the .Rmd code that you are trying to run and knit to Word. Potential helpers will also need to have your data (or a subset of the data, or some synthetic data that reproduces the problem).
See here for more detail:


Thank you, I actually figured it out.

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