普通情況下使用scan讀取數(shù)據(jù)
成都創(chuàng)新互聯(lián)專注于臨洮網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供臨洮營銷型網(wǎng)站建設(shè),臨洮網(wǎng)站制作、臨洮網(wǎng)頁設(shè)計(jì)、臨洮網(wǎng)站官網(wǎng)定制、小程序制作服務(wù),打造臨洮網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供臨洮網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
x <- scan("D:\\test.txt")
按列讀入,指定數(shù)據(jù)類型
x <- scan("test2dat.txt", what=list("",0,0)) #讀取三列數(shù)據(jù),第一列是字符,第二和第三列是數(shù)值 #以下寫法也可以 x2 <- scan("test2dat.txt", list(name="", num1=0,num2=0)) # 每個(gè)list都有個(gè)名字,分別為name,num1,num2
可以指定讀取的行數(shù),以下為讀取以逗號(hào)分割的csv文件的讀取方法
mydata <- read.table("test_nrow.txt.txt",sep=",", header=TRUE,nrow=5) #讀取除了表頭之外的5行數(shù)據(jù)
參考: http://www.biostat.jhsph.edu/~rpeng/docs/R-large-tables.html
tab5rows <- read.table("datatable.txt", header = TRUE, nrows = 5) classes <- sapply(tab5rows, class) tabAll <- read.table("datatable.txt", header = TRUE, colClasses = classes)
也可以用data.table 讀取大數(shù)據(jù)
install.packages("data.table") library(data.table) mydata <- fread("test.table.txt") #讀取文件時(shí)會(huì)顯示 Read **.*% of ***** rows, 讀取完畢會(huì)有提示 #查看文件的前6行 head(mydata)
參考:http://www.r-bloggers.com/reading-large-data-tables-in-r/
也可以使用ff包
setwd("D:/data test") library(ff) ffdf1 <- read.table.ffdf(file = "test.ido", header = TRUE, sep = "|")
參考: http://stackoverflow.com/questions/11782084/reading-in-large-text-files-in-r
http://www.bytemining.com/wp-content/uploads/2010/08/r_hpc_II.pdf
使用Python打開大數(shù)據(jù)的話,采用mmap
參考: http://stackoverflow.com/questions/11159077/python-load-2gb-of-text-file-to-memory
http://davetang.org/muse/2013/09/03/handling-big-data-in-r/
標(biāo)題名稱:R語言讀取大數(shù)據(jù)
當(dāng)前鏈接:http://jinyejixie.com/article14/ggsode.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、品牌網(wǎng)站制作、域名注冊、定制開發(fā)、網(wǎng)站導(dǎo)航、標(biāo)簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)