我正在尝试读取stata
大小为 320 MB 的文件,stata
其中R
包含超过 5000 个变量。我首先stata
使用读取文件,但它可以读取的最大变量是 5000。所以,我不能使用 stata 读取stata
文件。我的问题是:
有没有办法通过首先要求只保留变量(我知道变量)来读取
stata
文件stata
,以便变量的数量少于 5000?有没有办法可以读取这个
stata
文件R
?我正在使用 32 位 (Vista) 并R
给我错误。"Error: cannot allocate vector of size 21k.Kb"
.
我使用以下 R 代码读取文件:
#The stata file is in the webpage: http://www.federalreserve.gov/econresdata/scf/scf_2010survey.htm#STATADAT
#1. set mem 400m
set maxvar 4000
use p10i6.dta, clear
keep x8166 x8167 x8168 x8163 x8164 x2422 x2506 x2606 x2623 x604 x614 x623 x716 x507 x513 x526 x1706 x1705 x1806 x1805 x1906 x1905 x2002 x2012 x1409 x1509 x1609 x1415 x1515 x1615 x1417 x1517 x1617 x1619 x1621 x3124 x3224 x3324 x3129 x3229 x3329 x3335 x3408 x3412 x3416 x3420 x3424 x3428 x4020 x4024 x4028 x4018 x4022 x4026 x4030 x4022 x4026 x4030 x4018 x3507 x3511 x3515 x3519 x3523 x3527 x3506 x3510 x3514 x3518 x3522 x3526 x3529 x3804 x3807 x3810 x3813 x3816 x3818 x3930 x3721 x3821 x3823 x3825 x3827 x3829 x3822 x3824 x3826 x3828 x3830
save p10i6.dta, clear
#2.
library (foreign)
year<-2010
yr <- substr( year , 3 , 4 )
p10i6.dta<-read.dta(paste0( "p" , yr , "i6.dta" ))
saveRDS(p10i6.dta,file=paste0( "p" , yr , "i6.rda" ))
p10i6.rda<-readRDS(paste0( "p" , yr , "i6.rda" ))