Rstudio save and open blank Rmarkdown file - r

My Rmarkdown file appears to completely blank. I wrote my homework in a Rmarkdown file in Rstudio. But when I open it this morning, file Knit gave me blank windows.
Then, to check the setup way of previous Rmd, I open one Rmd file but Rstudio shown a blank file again.
So I follow the advice on the internet to "Reopen with Encoding", UTF-8 turned out helpful to show my previous Rmd.
But, when I click "Reopen with Encoding" on my hw4, all content disappeared, and none of encoding looks right for my hw4.
And I believe I did something with encoding last night when saving the file, because the final project blocked down R session for a couple of times and some windows jumped out to save the files with certain encoding. I also noticed that in direction the rmd file are 0KB, and Jupyter Notebook also open a blank file for me.
How can I recover the content of hw4 content? Are there any chance to recover it or I can just rewrite the whole file?

Related

downloading from a url with redirects

I am trying to download a files (it could be png, csv or pdf) from an internal url which seems to have redirects. I have tried downloading using download.file with extra=-L option, the download function from downloader package and the httr package.
However, in all cases I get a file of 768 B. Saving this file as a .txt shows that there is a another url within that. I have tried using that url, but without success. I see the following message (along with other information) in the downloaded file
Since your browser does not support JavaScript, you must press the Resume button once to proceed.
What works is if I stick that url in the browseURL function, I get a prompt to save the desired file.
I need to run the script in batch mode for reproducibility purposes, is there any way to run the browseURL in batch mode? or is there any other tool that would be useful here? (I have tried read.csv, fread etc. without any success). Unfortunately, I can't share the url as it is internal to my organization.
Thanks

cant get rscript to open in rstudio instead of web

I am supposed to access an rscript in my student account and save it but whenever I click on it instead of automatically opening rstudio it opens up in web browser as just texts.I cant figure how to get it to open in rstudio. can anyone help and explain why it won't open? I have to be save it as an rfile on my files but I cant since I cant get it there in the first place.
I would suggest save the file in your computer. Then open RStudio -> File -> Open File

How to open an external file from a Colab Jupyter notebook?

I have a Jupyter notebook in which I create an HTML file. I then open this HTML file in a new browser tab.
It's an R analysis, so I opened the HTML file using browseURL().
However, when I use a Colab hosted version of the notebook, nothing happens when I try to open the page.
Here's a reproducible example: https://colab.research.google.com/drive/1BfVDsDnXQwEpy4HwPKWkUC9Bpaz6r0Kv
Other things I tried that didn't work:
Using system2() instead of browseURL().
Setting the browser option to the open system tool via options(browser = "/usr/bin/open").
Is there another value for browser I should use? Is there a permission setting I should change?
Otherwise, how can I get the Colab notebook to display the HTML page I created?
As far as I know, Colab stores its files in Google Drive and judging by this link, Google doesn't support serving HTML from there.
You could save them as png files and display them like this if you're OK to have to install a few extra libraries.
install.packages('webshot')
webshot::install_phantomjs()
library(webshot)
webshot('https://www.halfbakery.com/', 'hb.png', delay = 2)
install.packages("png")
library(png)
img <- readPNG('hb.png')
grid::grid.raster(img)
I have tried it in Colab and it works there. I should add that browseURL still doesn't work on the file although double clicking on the file in the Files page does bring up a window with the png correctly displayed.

How to save files from Rstudio AMI EC2 on my local computer

I have installed Rstudio server Amazon EC2. It works fine, but I can't understand how to save files on my local computer...
In example,
x=5
write.csv(x,file="x.csv")
getwd()
[1] "/home/rstudio"
I can see the file in my working directory, but I cannot change w.d...
setwd("C:\\Users\\Paul\\Documents\\R")
Error in setwd("C:\\Users\\Paul\\Documents\\R") :
cannot change working directory
EDIT:
I get Network error: Connection timeout... if i use instructions from codingthis.com/platforms/ec2/… using Putty... Or "Host does not exist" if I use winSCP...
Any suggestions?
Best regards!
If you can't make SCP work, here's a simpler way. First I'll show how to save a plot, then how to save a CSV file that you've made with R.
You've started your EC2 instance of RStudio, thanks to helpful instructions elsewhere...
Now you've made a plot and you want to save that plot...
Look at the plot window for the "Export" button and click that, then click 'save plot as image' (or PDF if you prefer)
Follow the prompt and save it in the default location...
Now switch from the plot window to the files window by clicking on the 'Files' tab in RStudio... You should see your plot image file in the list there. Now click 'More' then "Export..."
You can edit the file name at this point...
And then after you click download it will download to your default download directory...
If you've used R to make a csv file of output, you can export that to your download directory in the same way, you can see my file 'd.csv', here with the checked box next to it in the 'Files' window. I've clicked on the 'More...' button, then 'Export...'
Now I can edit the name, click 'Download' and will go to my default download directory:
Does that answer your question? If your next question will be "how do I get files into RStudio on EC2?", please first experiment with the "Upload" button in the 'Files' window of Rstudio.

How can I recover the data of a corrupted css file in my local server?

While i was editing one of my css files, the power went out unexpectedly. After the power came back, i checked if the file was ok but it wasn't... it was corrupted, when opened in notepad it shows empty characters but the file size was not zero.
if you use chrome or another browsers, just give recover option when it asks when you open first time after the power shutdown. After the recovering process go to the "show code" option, copy and paste the code.
I faced the same issue recently and I found the solution. There is a corrupted file with extension .TMP. To fix it, download Notepad++ then go to the .TMP file and open the file with Notepad++. You can find your all css code in it. Just copy and paste into another blank css file and include that file in your html file. That's all.
I suffered for the same issue just now...and I've got the solution...and its simple.
Install this software called: Mini Tool Power Data Recovery
Its free and after it is installed, select the "Damaged Partition Recovery" from the first screen and navigate to the location of the file that is corrupted and select each corrupted file or the whole folder through the checkbox.
And click 'Save' and select where to save the recovered files. That's all, you should now see the original not-corrupted file there.
Thanks to Mini Tool Power Data Recovery.
Useful links:
https://www.powerdatarecovery.com/data-recovery-resources/corrupt-files.html
https://www.powerdatarecovery.com/free-file-recovery-software/how-to-recover-data-after-hard-drive-crash.html

Resources