简体   繁体   English

R:write.table是否包含变量名?

[英]R: write.table include variable names?

I have a datafile(math) and then I created ID variable. 我有一个数据文件(数学),然后创建了ID变量。 I tried to combine them into one datafile WITH all the variable names in 'math' and 'id'. 我试图将它们与所有在'math'和'id'中的变量名合并为一个数据文件。

I keep saving the combined file without variable names. 我一直保存不带变量名的合并文件。 I might have not used read.spss or write.table function properly. 我可能没有正确使用过read.spss或write.table函数。 What did I miss? 我错过了什么?

math="2009_Math.sav"
m=read.spss(math,use.value.labels=false)
mathid<-c(1:65535)
names(mathid)<-c("id")
mathfile<-data.frame(math,mathid)
write.table(m2009, file="math2009.sav",sep=",",row.names=F,col.names=T,quote=F,append=T)

Still not sure what you're asking, but I think what you want is: 仍然不确定您要问什么,但我认为您想要的是:

filename <- "2009_Math.sav"
m <- read.spss(filename, use.value.labels=false)
m$id <- 1:nrow(m)
write.table(m, file="math2009.csv",sep=",",row.names=F,col.names=T,quote=F,append=T)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM