data = 110列(x1:x100)(数字)
我正在尝试使用以下代码绘制所有列
file1 = open("new1.txt",'r')
file2 = open("new2.txt",'r')
NewFile = open("difference.txt",'w')
for line1 in file1:
for line2 in file2:
if line2 != line1:
NewFile.write(line1)
file1.close()
file2.close()
NewFile.close()
我还希望将摘要数据附加到图中的每一列进行某些分析。这有什么替代方案吗?
感谢。
答案 0 :(得分:0)
据我所知,你不能在facet_wrap的子图上添加字幕。您可以更改标题以适应您想要的内容。以下是min,max,mean和median的示例:
data = data.frame(x1=rnorm(100),
x2=rnorm(100),
x3=rnorm(100),
x4=rnorm(100),
x5=rnorm(100),
x6=rnorm(100))
library(dplyr)
library(tidyr)
library(ggplot2)
x <- data %>%
gather(variable,value) %>%
group_by(variable) %>%
mutate(mean=mean(value),
median=median(value),
min=min(value),
max=max(value),
lab=paste(first(variable),"\nMin:",round(min,2),"Mean:",round(mean,2),"Median:",round(median,2),"Max:",round(max,2)))
ggplot(x,aes(x = value)) +
facet_wrap(~lab,scales = "free_x") +
geom_histogram(aes=(density)) +
geom_vline(aes(x=mean))