Knitr Getting "Stuck" When Adding Any Code to a R Markdown File - r

Although recently I have been encountering an issue with the Knit function "stalling" as in the output in the consul only makes it through 66% of the first "unnamed code chunk" and never progresses any further (screenshot).
With the above screen shot I downloaded a .RMD file and it Knit just fine the first time when I just added my name (but no code), but when I add anything for code (as I have in the screenshot) it gets "stuck" and never progresses past what you see in markdown console. (Sorry this screenshot is an example .RMD File I am using from my grad stats class.)
The other week I had this issue with some data and resolved it by changing the folder where the .RMD file was saved and that seemed to fix it that time. Although now I am encountering the issue again and I cannot seem to fix it this time.
The first time it seemed to be due to me storing all my files on google drive which synchronizes with my computer and maybe R struggles with processing the intermediate files? Thus that time once I saved the file to my desktop and directed the output file there it worked. Although I have also tried to save the files all in a folder on my desktop this time and it seems to not resolve the issue.
Has anyone had this issue of knitr stalling indefinitely or know what the root cause may be. This has been happening to all my .RMD files lately (and I have uninstalled and reinstalled r/rstudio).
Cheers!
-Nathan

Related

"The system cannot find the file specified whenever I knit"

Whenever I knit to a PDF in RStudio, the error "The system cannot find the file specified."
Here is the code that I'm using:
##importing data
library(readr)
Quiz1data_2 <- read_csv("C:/Users/erinp/Downloads/Quiz1data-2.csv")
I have restarted RStudio multiple times and I have copied and pasted the exact link that my file is saved to and it's still not working.
What am I not seeing or what am I not thinking?
Some suggestions/questions:
Without knitting, when you run the line reading in the csv, does it work?
Also, are you sure that the error is referring to the data csv? Could it be referring to the (I'm assuming) markdown file you are writing your code in? Have you moved that file since you started working in it?
Are you able to knit other documents to pdf? You need MiKTeX on a windows machine. Does knitting to html work?
I've found R to be a little tricky reading in files. I usually use the base function like this:go to the environment tab>import dataset>from text(base)> (select the file you want, hit open)>(select settings so that the dataframe preview looks right>import. Code that does this will run in the console, and I copy it into my markdown file so that every time it knits, it replicates that successful process.
I figured it out. It's because I forgot to assign a value to an object so it wouldn't knit into a PDF. I made a comment earlier, but it's small so I thought I would add this to the answer section.

I have issues with saving my script in R x64 on my windows 10 pc, with crashing etc

Every time I work on a script in R I come across the problem, that R isn't able to save my script, although I don't use problematic file names and put an .R in the name. I get an error message where the pathname is displayed, as to show me that there is a problem with that. I tried copy-pasting my script into a new one, but the problem persists with the new script file. Furthermore, when I try to copy the text and paste it after having restarted R (the console), it does not work. The scripts, the original one which has stayed blank, as saving did not work, or a new blank one, stay blank when trying to past text.
I should add that R seems to crash when it tries to save the original script that is not savable. When I close the console, R warns me that I have not saved the script, so I press on save before closing. Then R seems to save it, but ultimately crashes.
Later on, I realized that the copy-pasting does not work on my computer at all. I think this problem only started from the moment on I could not save my script in R.
I would be grateful for support from the community.
I'll have an exam where we need to upload our script, so I really need the saving to work.
Greetings,
J.C.

My R script has been turned entirely into blank spaces. Is this recoverable?

If I knew how to reproduce this then I would, but I have never encountered this before. I saved my work using RStudio as I normally would, saving the progress of writing my R script. But when I opened it the next day, the entire script has been blanked. It still has the same file size as before, but nothing appears when I open it in RStudio. It just has a blank line 1.
If I open the script in Notepad++ I can see that the entire file has NUL characters. What has happened here? Is this recoverable?

Lost code in Rstudio- r script is blank after computer crash

I was working in Rstudio and had previously successfully saved a file/Rscript. Sometime later, i was working on the same file and the computer froze, so I turned it off because I hadn't made much progress on the original work. When i reopen R, this file still exists on my computer but when loaded into R, the file is blank except for one line of: "........................................", i.e. a really long elipsis, which was highlighted in red.. Any help on how I can get my original code back?

Generating Excel file with XLConnect-Removed Feature: Format from /xl/styles.xml part (Styles)

I am using XLConnect in R for the purpose of daily report generation. I have a program that runs automatically at specific time to append the data for most recent date daily into an excel file (Excel 2007). The program works fine to do this task. But, sometimes when i open the excel file it says that "Excel found unreadable content. do you want to recover the content of this workbook?"
The best part of this issue is that i can't reproduce this issue again to know the exact root cause for the problem. It arises in a random manner. Because, when i try to run the program again it works fine. Can somebody help me to identify the root cause?

Resources