码迷,mamicode.com
首页 > 其他好文 > 详细

R in action -- 2.3 数据输入

时间:2017-07-06 00:33:50      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:rtm   安装   excel导入   pac   window   ecif   ble   文件   xls   

R in action -- 2.3 数据输入

1、从CSV文件导入数据

> gtades <- read.table("1.csv",header=TRUE,sep=",")
> gtades
  ID name age
1  1  qqw  15
2  2  eew  56
3  3  rrw  43
4  4  ttw  58

2、从Excel导入数据

安装openxlsx包 

> install.packages("openxlsx")
Installing package into ‘C:/Users/iamfe/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependency ‘Rcpp’

trying URL ‘https://cran.rstudio.com/bin/windows/contrib/3.4/Rcpp_0.12.11.zip‘
Content type ‘application/zip‘ length 3380346 bytes (3.2 MB)
downloaded 3.2 MB

trying URL ‘https://cran.rstudio.com/bin/windows/contrib/3.4/openxlsx_4.0.17.zip‘
Content type ‘application/zip‘ length 2430742 bytes (2.3 MB)
downloaded 2.3 MB

package ‘Rcpp’ successfully unpacked and MD5 sums checked
package ‘openxlsx’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\iamfe\AppData\Local\Temp\Rtmp6h0MaS\downloaded_packages
> library(openxlsx)
> read.xlsx("1.xlsx")
  ID name age
1  1  qqw  15
2  2  eew  56
3  3  rrw  43
4  4  ttw  58
> 

 

 

 

R in action -- 2.3 数据输入

标签:rtm   安装   excel导入   pac   window   ecif   ble   文件   xls   

原文地址:http://www.cnblogs.com/matplot/p/7124063.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!