简体   繁体   English

保存 R 脚本会导致空文件

[英]Saving an R-Script results in empty file

I have recently started using R for uni.我最近开始将 R 用于 uni。 I want to save my code using either save as or ctrl+s .我想使用save asctrl+s来保存我的代码。 However, the saved file is empty more often than not.但是,保存的文件通常是空的。 For some reason, the files save normally on a few occasions.出于某种原因,文件有时会正常保存。 However, they also became empty after saving changes to the script.但是,在保存对脚本的更改后,它们也变空了。

I couldn't find any solution for the problem, neither here nor anywhere else.我找不到任何解决这个问题的方法,无论是在这里还是其他任何地方。

I am using RStudio installed via Anaconda on an Windows 10 x64 Notebook, if that helps.如果有帮助,我正在使用通过 Anaconda 在 Windows 10 x64 笔记本上安装的 RStudio。

Thanks a lot for the responses!非常感谢您的回复! I'd be glad to provide more details if needed!如果需要,我很乐意提供更多详细信息!

This is what the saved files look like from File Explorer:这是文件资源管理器中保存的文件的样子:

“R-Datei”类型的七个文件的列表,其中只有一个具有非零大小

I just meet the exactly same problem.我只是遇到了完全相同的问题。 I solved it by checking and changing RStudio -> File -> "Save as Encoding" from "ISO-8859-1 (System default)" to "UTF-8", then the file was saved.我通过检查并将 RStudio -> 文件 -> “另存为编码”从“ISO-8859-1(系统默认)”更改为“UTF-8”来解决它,然后保存文件。 I'm trying to recover my previous 0kb files...我正在尝试恢复我以前的 0kb 文件...

i couldn't reproduce the error but i also don't like to use the anaconda environment.我无法重现该错误,但我也不喜欢使用 anaconda 环境。

if the problem is saving the text file than may i suggest to do just that and save the code in a regular .txt file?如果问题是保存文本文件而不是我建议这样做并将代码保存在常规的 .txt 文件中?

if this is not an option you can try to find out what happens if you save the r studio code on a different drive (or usb/flash drive)如果这不是一个选项,您可以尝试找出如果您将 r studio 代码保存在不同的驱动器(或 USB/闪存驱动器)上会发生什么

########################################################### ################################################# #########

EDIT 14.07.2022编辑 14.07.2022

Interestingly enough, just today (14.07.2022) I had the same problem.有趣的是,就在今天(14.07.2022)我遇到了同样的问题。 After installing R 4.2.1 everything worked fine until I changed the encoding (from utf-8 to windows 1252), at which point all the files in my project were overwritten and are now empty.安装 R 4.2.1 后一切正常,直到我更改编码(从 utf-8 到 windows 1252),此时我项目中的所有文件都被覆盖并且现在是空的。 Changing back to an older version of R (4.1.3) allowed me to display/save/use all scripts again (from backups).改回旧版本的 R (4.1.3) 允许我再次显示/保存/使用所有脚本(来自备份)。

Using the answer provided by @Shidan it is possible to open the data in R-4.2.1 as well.使用@Shidan 提供的答案,也可以在 R-4.2.1 中打开数据。

This problem does not seem to be connected to Anaconda but an encoding issue between Rstudio and any R distribution above (and including) 4.2.此问题似乎与 Anaconda 无关,而是 Rstudio 与任何高于(包括)4.2 的 R 发行版之间的编码问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM