楼主: cqy0202
2989 7

[Splus与R初级班] 关于数据导入 [推广有奖]

  • 0关注
  • 1粉丝

VIP

本科生

86%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
883 点
帖子
63
精华
0
在线时间
119 小时
注册时间
2009-4-6
最后登录
2016-12-30

楼主
cqy0202 发表于 2009-10-25 22:05:25 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
老师好,在R中,我将excel文件转换成csv格式后,用read.csv导入是成功的,但为什么在Splus中就不行呢?Splus中究竟怎样才能导入excel格式的文件?另外,我在Splus中可以直接点击按键打开excel表格,但我又不知道怎么把这个表格跟commands框连接起来,让它可以操作起来,很着急,  请教老师了!谢谢!
二维码

扫码加我 拉你入群

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

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

关键词:数据导入 Commands Command excel表格 Excel格式 数据

沙发
ruiqwy 发表于 2009-10-26 10:16:11
SPLUS可以直接读入EXCLE格式的数据的。
比如:
dat=importData(file="文件名.xls",type="EXCEL")  就可以了
R is the second language for me!Using R is standing on the shoulders of giants!   Let\'s use R together!

藤椅
cqy0202 发表于 2009-10-26 11:07:35
老师,不行呀,我把工作目录改到我文件存放的地方,输入 dat=import.data(file="01.xls",type="excel")然后出现了这样的提示:
Problem in import.data: argument type= not matched: import.data(file = "01.xls", type = "excel")
Use traceback() to see the call stack
可我的明明是excel文件呀。怎么办才好呀?

板凳
cqy0202 发表于 2009-10-26 11:11:35
对了,后面的excel我是用大写的,可还是不行,不知道是为了什么,麻烦老师了。

报纸
ruiqwy 发表于 2009-10-26 15:08:59
是importData  不是import.data注意大小写哦
R is the second language for me!Using R is standing on the shoulders of giants!   Let\'s use R together!

地板
cqy0202 发表于 2009-10-26 15:37:54
抱歉,老师,我自己都觉得不好意思了,好笨的感觉,我把import.data改成importData了,中间没有点号的,也就是dat=importData(file="01.xls",type="EXCEL"),可回车后,只出现了+号,其他什么都没了,好像程序没写完一样,importData是执行命令吗?

7
ruiqwy 发表于 2009-10-26 17:57:36
不急,慢慢来,刚学都是这样的,等熟练了以后就轻松了!
出现+号 是程序不完整,建议在半角下重新写一下 ""和()。SPLUS只能识别半角下的标点符号!
importData是SPLUS用来读入外部数据的主要函数。它的功能非常强大。
USAGE:
importData(file=NULL, type="", keep=character(0), drop=character(0),
   colNames=character(0), rowNamesCol=-1, filter=character(),
   format=character(0), delimiter=<<see below>>,
   startCol=1, endCol=-1, startRow=1, endRow=-1, pageNumber=-1, colNameRow=-1,
   server="", user="", password="", database="", table="",
   stringsAsFactors=<<see below>>, sortFactorLevels=T,
   valueLabelAsNumber=F, centuryCutoff=1930, separateDelimiters=T,
   odbcConnection=character(0), odbcSqlQuery=character(0),
   sqlQuery=character(0), readAsTable=F, colNamesUpperCase=F,
   time.in.format=character(0), decimal.point=".", thousands.separator=",",
   time.zone="GMT", use.locale=F, sqlReturnData=T,
   scanLines=max(startRow, 256), maxLineWidth=0, na.string="NA",
   colTypes=character(0), bigdata=F)

OPTIONAL ARGUMENTS:
file
a character string specifying the name of the file to import. If the file has a known suffix (see the type argument below), S-PLUS assumes the file is of that type. This can be overridden by providing type explicitly. The file argument is not required if importing from a relational database.
type
a character string specifying the type of file to import. Possible values are listed here; the case of the character string is ignored.
"ACCESS"
Microsoft Access file. This file type is available only in S-PLUS for Windows. See the DETAILS section for information on import/export limitations. File suffix: mdb.

"ASCII"
ASCII text. 32k is the maximum import/export character string length. File suffix: asc, csv, or txt. S-PLUS for Windows also recognizes the suffixes dat and prn.
"DBASE"
dBase or other xBase file. File suffix: dbf.
"DIRECT-DB2"
DB2 database connection. See the DETAILS section for information on import/export limitations. No file argument should be specified.
"DIRECT-ORACLE"
Oracle database connection. See the DETAILS section for information on import/export limitations. No file argument should be specified.
"DIRECT-SQL"
Microsoft SQL Server database connection. See the DETAILS section for information on import/export limitations. No file argument should be specified. This option is available only in S-PLUS for Windows.
"DIRECT-SYBASE"
Sybase database connection. No file argument should be specified.
"EPI"
Epi Info file. File suffix: rec.
"EXCEL"
Microsoft Excel worksheet file. 32k is the maximum import/export character string length. File suffix: xls.
"FASCII"
Formatted ASCII text file. File suffix: fix. S-PLUS for Windows also recognizes the suffix fsc.
"FOXPRO"
FoxPro file. This file type is available only in S-PLUS for Windows. File suffix: dbf.
"GAUSS"
Aptech Gauss data file (old format). Unix exports GAUSS files in GAUSS96 format. File suffix: dat.
"GAUSS96"
Aptech Gauss data file (new format). File suffix: dat.
"LOTUS"
Lotus 123 worksheet file. File suffix: wk* or wr*.
"MATLAB"
Matlab file. The file must contain a single matrix. File suffix: mat.
"MINITAB"
Minitab workbook. In S-PLUS for UNIX, the file must be from Minitab Version 11 or earlier. File suffix: mtw.
"ODBC"
ODBC connection. This file type is available only in S-PLUS for Windows. When you specify "ODBC" , you must also specify the argument odbcConnection. You can also specify the argument odbcSqlQuery with this type. For more information, see the ODBC arguments described below.
"ORACLE"
Oracle database connection. Same as "DIRECT-ORACLE". No file argument should be specified.
"PARADOX"
Paradox data file. This file type is available only in S-PLUS for Windows. File suffix: db.
"QUATTRO"
Quattro Pro worksheet file. File suffix: wq* or wb*.
"SAS", "SAS6WIN"
SAS Version 6.x data file from Windows or OS/2. File suffix: sd2.
"SAS1", "SAS6UX32"
SAS Version 6.x data file from HP, IBM or Sun UNIX. File suffix: ssd01.
"SAS4", "SAS6UX64"
SAS Version 6.x data file from Digital/Compaq/HP Tru64 UNIX. File suffix: ssd04.
"SAS7"
SAS Version 7 or later data file from Windows or UNIX. File suffix: sas7bdat.
"SAS7WIN"
SAS Version 7 or later data file from Windows. This is equivalent to the "SAS7" file type since the platfrom is autodetected. File suffix: sas7bdat.
"SAS7UX32"
SAS Version 7 or later data file from Solaris (SPARC), HP-UX, or IBM AIX. This is equivalent to the "SAS7" file type since the platfrom is autodetected. File suffix: sas7bdat.
"SAS7UX64"
SAS Version 7 or later data file from Digital/Compaq/HP Tru64 UNIX. This is equivalent to the "SAS7" file type since the platfrom is autodetected. File suffix: sas7bdat.
"SAS_TPT"
SAS transport file. File suffix: tpt or xpt.
"SIGMAPLOT"
SigmaPlot data file. This file type is available only in S-PLUS for Windows. File suffix: jnb.
"SPLUS"
S-PLUS transport file. Files in this format can also be written and read with the data.dump and data.restore functions. File suffix: sdd.
"SPSS"
SPSS data file. File suffix: sav.
"SPSSP"
SPSS portable data file. File suffix: por.
"STATA"
Stata Version 2.0 or later data file. File suffix: dta.
"SYBASE"
Same as "DIRECT-SYBASE". Sybase database connection. No file argument should be specified.
"SYSTAT"
Systat data file. File suffix: sys. S-PLUS for Windows also recognizes the suffix syd.
R is the second language for me!Using R is standing on the shoulders of giants!   Let\'s use R together!

8
cqy0202 发表于 2009-10-26 19:33:19
太棒了,老师,成功了,非常感谢老师!
老师,我还有一个问题,我导入的是带时间的excel数据框,到了Splus这里需要用ts等命令把它转换成时间序列再进行分析还是直接进行分析?

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-19 13:30