首页 > 代码库 > R in action -- 2.3 数据输入
R in action -- 2.3 数据输入
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 数据输入
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。