楼主: 比日暮
41297 12

[问答] R语言初学读入数据出错求大神解救! [推广有奖]

  • 0关注
  • 0粉丝

初中生

57%

还不是VIP/贵宾

-

威望
0
论坛币
676 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
137 点
帖子
8
精华
0
在线时间
25 小时
注册时间
2012-10-13
最后登录
2020-8-31

楼主
比日暮 发表于 2016-5-22 18:43:43 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
刚学习R语言,老师给的.Rdata格式的文件(我也不知道源文件是本文件还是excl文件啥的),我就打不开了~~~~(>_<)~~~~ ,载入foreign包也不行,大神帮忙看看这到底问题出在哪里了啊?该怎么解决呢?万分感谢!!
情况一:
> dfrm<-read.table("G:/课件及作业/R语言建模/Rdata for homework/example2_5.RData")
Error in make.names(col.names, unique = TRUE) :
  invalid multibyte string 1
In addition: Warning messages:
1: In read.table("G:/课件及作业/R语言建模/Rdata for homework/example2_5.RData") :
  line 1 appears to contain embedded nulls
2: In read.table("G:/课件及作业/R语言建模/Rdata for homework/example2_5.RData") :
  line 4 appears to contain embedded nulls
3: In read.table("G:/课件及作业/R语言建模/Rdata for homework/example2_5.RData") :
  incomplete final line found by readTableHeader on 'G:/璇句欢鍙婁綔涓?R璇█寤烘ā/Rdata for homework/example2_5.RData'
情况二:添加head=TRUE以后
>dfrm<-read.table("G:/课件及作业/R语言建模/Rdata for homework/example2_5.RData",head=TRUE)
Error in make.names(col.names, unique = TRUE) :
  invalid multibyte string 1
In addition: Warning messages:
1: In grepl("\n", lines, fixed = TRUE) :
  input string 1 is invalid in this locale
2: In grepl("\n", lines, fixed = TRUE) :
  input string 1 is invalid in this locale
3: In grepl("\n", lines, fixed = TRUE) :
  input string 1 is invalid in this locale
4: In read.table("G:/课件及作业/R语言建模/Rdata for homework/example2_5.RData",  :
  line 1 appears to contain embedded nulls
5: In read.table("G:/课件及作业/R语言建模/Rdata for homework/example2_5.RData",  :
  line 4 appears to contain embedded nulls
6: In read.table("G:/课件及作业/R语言建模/Rdata for homework/example2_5.RData",  :
  incomplete final line found by readTableHeader on 'G:/璇句欢鍙婁綔涓?R璇█寤烘ā/Rdata for homework/example2_5.RData'

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:读入数据 R语言 Rdata格式 我也不知道 RData 源文件

沙发
bbslover 在职认证  发表于 2016-5-22 19:03:25
对于*.Rdata数据格式,要使用:load("*.Rdata"),而不是read.table()函数。查看一下load()和read.table()。
已有 2 人评分经验 论坛币 学术水平 热心指数 收起 理由
crystal8832 + 10 + 1 + 1 + 1 精彩帖子
jiangbeilu + 10 + 2 精彩帖子

总评分: 经验 + 10  论坛币 + 11  学术水平 + 1  热心指数 + 3   查看全部评分

藤椅
比日暮 发表于 2016-5-22 19:29:31
bbslover 发表于 2016-5-22 19:03
对于*.Rdata数据格式,要使用:load("*.Rdata"),而不是read.table()函数。查看一下load()和read.table()。
再请问一下,load完以后该如何显示出来文件里面具体的数据内容啊?不好意思啊,太小白了。。万分感谢!!

板凳
比日暮 发表于 2016-5-22 19:33:49
bbslover 发表于 2016-5-22 19:03
对于*.Rdata数据格式,要使用:load("*.Rdata"),而不是read.table()函数。查看一下load()和read.table()。
苍天啊,我看见了~~~谢谢谢谢谢~~~!!!!

报纸
huangpengfei 发表于 2017-2-6 22:28:51
bbslover 发表于 2016-5-22 19:03
对于*.Rdata数据格式,要使用:load("*.Rdata"),而不是read.table()函数。查看一下load()和read.table()。
读取.xlsx文件时,报错Error in make.names(col.names, unique = TRUE) :
  invalid multibyte string 1 是啥原因?怎么解决?谢谢

地板
bbslover 在职认证  发表于 2017-2-7 20:55:52
huangpengfei 发表于 2017-2-6 22:28
读取.xlsx文件时,报错Error in make.names(col.names, unique = TRUE) :
  invalid multibyte string  ...
建议 1:使用csv格式文件
2:搜索支持xls格式的R packages

7
抠脚女汉 发表于 2017-4-13 11:21:04
bbslover 发表于 2017-2-7 20:55
建议 1:使用csv格式文件
2:搜索支持xls格式的R packages
R读取文本文档数据出现如下错误Error in make.names(col.names, unique = TRUE) :
  invalid multibyte string 18,是怎么回事呢

8
276089470 发表于 2017-10-10 17:20:47
I understand the reason.

I found some source and other IO functions which read the source code from file. On my courses, these scripts are stored with encoding UTF-8, but the default chinese encoding for Chinese Traditional windows users are BIG5. Similar issues might be occurred for other non-English courses.

The solution is to add the argument encoding = "UTF-8", in my case, to these functions or connections. More generally, providing the default encoding or a hook before parsing might be a more robust solution.

Best,
已有 2 人评分学术水平 热心指数 信用等级 收起 理由
BankerBOOM + 1 + 1 + 1 精彩帖子
alecwf + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

9
henchli 学生认证  发表于 2018-10-5 19:44:47
276089470 发表于 2017-10-10 17:20
I understand the reason.

I found some source and other IO functions which read the source code fr ...
The setting "encoding = "UTF-8" is really important in reading Chinese character. "Thank you very much!

10
alecwf 发表于 2018-11-6 15:44:10
"encoding = "UTF-8"  加了之后,line 1 appears to contain embedded nulls

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 22:51