0

Why can the chunk be run interactively but there is an error when I try to knit the file? When I run each chunk, there is no error, but when I knit it, it is stopped by an error.

The capture of the error

emilliman5
  • 5,816
  • 3
  • 27
  • 37
X.DONG
  • 1
  • 1
  • 1
    Welcome to SO! please have a look at how to make a minimal workable example. http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – emilliman5 Apr 25 '18 at 13:54
  • 1
    Please put your code in a code block, not as an image. – divibisan Apr 25 '18 at 14:12

1 Answers1

1

The usual reason for a difference between the interactive result and the knitted document result is that you are referring to objects that aren't defined in the document. Interactive code can see your global environment, knitted code can't.

user2554330
  • 37,248
  • 4
  • 43
  • 90