The code ran correctly in R without trying to use RMarkdown
Then you created a RMarkdown document and that succeeded well
Then you tried to publish the document with clicking the Publish Document button in the viewer
??
If that is the case I cannot help you (no experience with Publish).
If it went wrong somewhere else, please create a small example (extract) of your Rmd or R file,
so that we can pinpoint the problem.
Hi @HanOostdijk, yes thats correct, It ran fine with R, also with knitr, but when I try to publish there was this error. sorry for not clarifying that.