This seems like a connectivity issue, R is not being able to connect to the CRAN repository you have selected, these are some things to try.
Choose a different CRAN repository, RStudios repository is a good choice (http://cran.rstudio.com/) or you could choose one that is geographically closer to you.
Check if your internet connection has traffic restrictions of some kind, like a firewall, proxy server, etc. This is usually the case when you are at work or school.
We like to keep things tidy around here so please ask only one question per topic, if you have distinct questions you can always open a new topic.
I'm going to shortly adress your other questions. You should not include install commands in a Rmd file because you only need to install packages once, not every time you knit a document, you only need to load the packages with library().
About the missing data frame, when you knit a Rmd document the code gets executed in a clean environment other than the one you are currently working on so you have to include the necessary code to read the data frame into memory.
If you need further assistance with any of this, please open a new specific topic for it.