在data.frames中找到相等的列 [英] Find equal columns in data.frames

查看:34
本文介绍了在data.frames中找到相等的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个data.frame对象'x'和'ans1','x'中有500列,'ans1'中有7列
如何从'x'中找到列名等于'ans1'中的列?

I have two data.frame objects 'x' and 'ans1', there are 500 columns in 'x' and 7 in 'ans1' How can I find names of columns from 'x', which are equal to columns from 'ans1'?

推荐答案

使用%in%

names(x) %in% names(ans1)

有关更多详细信息,请参见?match

See ?match for more detail.

这篇关于在data.frames中找到相等的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆