简体   繁体   English

如何使R读取CSV文件中的全部数据,而不是部分数据?

[英]How to make R to read full data in CSV file, instead of a partial of it?

R for Win 3.6.1 / RStudio / Miktex 2.9 (all are latest versions) installed on a 4G RAM laptop (i5) / 12G RAM desktop(AMD Phenom)/ 16G RAM desktop (Ryzen 5 2600). R for Win 3.6.1 / RStudio / Miktex 2.9(均为最新版本)安装在4G RAM笔记本电脑(i5)/ 12G RAM台式机(AMD Phenom)/ 16G RAM台式机(Ryzen 5 2600)上。

I ran a onclass code to read csv file (the code as below attached) but could only read a partial of the full data (26,116 rows of 44,000 around in total, with 16 variables read among the total 18 variables). 我运行了一个onclass代码来读取csv文件(如下所示的代码),但是只能读取全部数据的一部分(总共264,000行,共44,000个数据,总共18个变量中有16个变量)。 Checked with the professor and confirmed the code is correct, other students ran the same code well, but on my 3 PCs the results are the same. 与教授核对并确认代码正确无误,其他学生则很好地运行了相同的代码,但是在我的3台PC上,结果是相同的。 The professor and I haven't figured out the reason. 教授和我还没有弄清楚原因。

la <- read.csv('https://douglas2.s3.amazonaws.com/data/LA.csv', stringsAsFactors=F)

Uninstalled the existing 3 softwares (R, RStudio, Miktex), restarted before reinstall the latest versions of them; 卸载现有的3个软件(R,RStudio,Miktex),然后重新安装它们的最新版本; Download the file to local disk and read.csv from local disk. 将文件下载到本地磁盘,然后从本地磁盘读取.csv。

la <- read.csv('https://douglas2.s3.amazonaws.com/data/LA.csv', stringsAsFactors=F)

Expected result: Read the full size data of the file (about 44,000 rows and 18 columns) Actual result now: Can only read 26,116 rows and 16 columns on 3 different PCs with (4G/12G/16G RAM). 预期结果:读取文件的完整大小的数据(大约44,000行和18列)现在的实际结果:在具有(4G / 12G / 16G RAM)的3台不同PC上,只能读取26,116行和16列。 Other peers (students on class) have no such a problem (codes are same - distributed directly by the professor). 其他同伴(班上的学生)则没有这样的问题(代码相同-由教授直接分发)。

(Posted a solution on behalf of the question author, to move it from the question to the answer space) . (代表问题作者发布了一个解决方案,以将其从问题移动到答案空间)

Sorry for my mistake - Yes, it is a 16 columns dataframe, not 18. Sorry! 抱歉,我的错误-是的,它是一个16列的数据框,而不是18。抱歉! :-DI used read_csv and I could read the full 44000+ rows. :-DI使用read_csv,我可以读取全部44000+行。 However, I can't do that no matter How I tried on my win10 1903 (may2019 version) laptop and desktops - one is MacAir, the other 2 desktops are AMD systems. 但是,无论我如何在win10 1903(may2019版本)笔记本电脑和台式机上进行尝试,我都无法做到这一点-一个是MacAir,另外两个台式机是AMD系统。

The interesting point is that, when I switched back to (dual systems) MacOS and installed R, RStudio & Mactex (same "components") on that, the problem disappeared - I can easily and much much much faster (almost immediate) to get the full rows read into the environment. 有趣的一点是,当我切换回(双系统)MacOS并在其上安装R,RStudio和Mactex(相同的“组件”)时,问题就消失了-我可以轻松快捷地(几乎立即)获得该问题。全部行读入环境。 That's so mysteroius. 真是个谜。

So, I feel that the problem has no relationship to hardwares (both Intel & AMD systems were tested). 因此,我认为该问题与硬件无关(已测试Intel和AMD系统)。 The only clue perhaps is the newly upgraded Win10 1903 version. 唯一的线索可能是新升级的Win10 1903版本。 Since on MacOS, nothing is abnormal. 由于在MacOS上,没有异常。 Strange. 奇怪。

Accordingly, I stick to MacOS when I am handling R class in this term. 因此,在本学期处理R类时,我坚持使用MacOS。 I was almost purchasing a new Thinkpad X1 Carbon due to the problem. 由于这个问题,我几乎要购买新的Thinkpad X1 Carbon。 My last trial within MacOS saved me $1,500+. 我在MacOS上进行的最后一次试用为我节省了$ 1,500 +。

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

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