Your code was invisible because this forum also uses Markdown to format posts, so the forum software was actually trying to run your code! I edited the original post to properly format the code, so now it shows up.
If you’re still getting an error when you try to knit to word_document, it might help to include more of the output from the R Markdown console (formatted as code, please!)
Since knitting to PDF can involve some tricky external system dependencies (i.e., LaTeX), I tested this on RStudio Cloud so that at least the setup isn't idiosyncratic to my specific machine and its checkered past! (I got the same results on my own machine though). Here's a link to a shared project, if you want to play with it there: https://rstudio.cloud/project/103903
I can knit to word_document and default (self-contained) html_document just fine with http://-linked images (both outputs contain two adorable kittens ). You can inspect/download the successfully output HTML and Word files from the Files pane of the Cloud project.
Knitting to pdf_document fails with the error:
! Package pdftex.def Error: File `http://www.online-image-editor.com//styles/20
14/images/example_image.png' not found.
I've been searching around a bit, and I can't really confirm that it's supposed to be possible to use http:// URLs in image links when the output is PDF — the pandoc documentation only has a local path example. I'm reaching the end of my understanding of the intricacies of the handoff between rmarkdown, knitr, and pandoc here, so I hope somebody else will come along and shed some more light.