r - Is there a R function to print & export column names to excel?
问题描述
Im trying to append survey data sets of different versions of the survey to create a master file. But, the different survey versions do not have uniform number of columns across. ( E.g : V1 - 10k vars, V2- 20k vars). I would like to see what are the 10k missing vars in V1 in comparison to V2.
Is there a R function which could print & export the colnames of the data to excel?
Thank you.
解决方案
First, you can make a dataframe of column names:
df1_names <- as.data.frame(colnames(df1))
df2_names <- as.data.frame(colnames(df2))
If you want your column names across rows (wide instead of long), you can transpose them:
df1_names <- as.data.frame(t(df1_names))
df2_names <- as.data.frame(t(df2_names))
Then, using the xlsx
package, you can write to Excel:
write.xlsx(df1_names, filename)
write.xlsx(df2_names, filename)
推荐阅读
- android - 我在运行命令时遇到这些错误(npx react-native init AwesomeProject)
- javascript - 如何在 Cognos 的日期提示中将月份的第一天设置为默认值
- android-studio - Facebook 个人资料图片未在 android studio 中显示,我同时使用了 glide 和 Picasso
- html - 关注复选框与复选框边框和轮廓不一致
- python - 枕头包是必需的,但我已经有最新版本
- google-cloud-platform - GCP 中是否有中央 API 或语言库来标记所有资源?
- javascript - 我在 Javascript 上的突破克隆的暂停/播放按钮
- javascript - Angular js控制器不向mvc控制器发送数据
- c++ - 从标记为 extern C 的函数调用损坏的类实例方法
- keras - Understanding Keras batch_size vs. batch dimension for LSTM