比较列名并绘制图 [英] compare column names and make plots

查看:57
本文介绍了比较列名并绘制图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想比较两个数据帧中的两个列名,并使用原始数据帧中匹配的列名创建图形.

I want to compare two columnnames from two data frames and create graphs with the matched columnnames from the original data frames.

a<-data.frame(a1=c(1,2,3,4,5),a2=c(2,3,4,5,6),b1=c(3,4,5,6,7),c1=c(4,5,6,7,8))
b<-data.frame(c1=c(10,20,30,40,50),b1=c(20,30,40,50,60),d1=c(30,40,50,60,70))

输出应类似于: 情节(b $ c1,a $ c1) 情节(b $ b1,a $ b1)

Output should be like: plot (b$c1,a$c1) plot (b$b1,a$b1)

我可以使用上述代码创建图,但是由于我的数据框太大,我需要将其自动化.

I can create the plots with the above codes, but I need it to be automated because my dataframe is too large.

推荐答案

这是一种方法:

shared.names <- intersect(names(a), names(b))
par(mfrow=n2mfrow(length(shared.names)))
for (name in shared.names) plot(a[[name]], b[[name]], main=name)

这篇关于比较列名并绘制图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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