具有可变值的R命名图
我正在尝试从文件集合生成绘图,并根据输入文件标记每个绘图,我的尝试如下:具有可变值的R命名图,r,R,我正在尝试从文件集合生成绘图,并根据输入文件标记每个绘图,我的尝试如下: nd_list<- lapply(nd_results,readRDS) filenames<-as_vector(nd_results)%>% str_remove("_difference.RDS") i=0 plot_p_values<-function(nanodisco_rds){ plot_list<-list() i=i+1 plot_
nd_list<- lapply(nd_results,readRDS)
filenames<-as_vector(nd_results)%>%
str_remove("_difference.RDS")
i=0
plot_p_values<-function(nanodisco_rds){
plot_list<-list()
i=i+1
plot_list[[i]]<-ggplot(nanodisco_rds,aes(t_test_pval))+ geom_histogram(bins=100)+ labs(title = filenames[i] x="T test P value")+ scale_y_continuous(labels = function(x) format(x, scientific = FALSE))
}
nd\u list您可以尝试:
library(ggplot2)
plot_p_values<-function(nanodisco_rds, file){
plot_list <- vector('list', length(nanodisco_rds))
for(i in seq_along(nanodisco_rds)) {
plot_list[[i]]<- ggplot(nanodisco_rds[[i]],aes(t_test_pval)) +
geom_histogram(bins=100)+
labs(title = file[i], x="T test P value")+
scale_y_continuous(labels = function(x) format(x, scientific = FALSE))
}
plot_list
}
result <- plot_p_values(nd_list, filenames)
库(ggplot2)
plot_p_值请修复代码。如图所示,它不会绘制任何内容。如果您创建一个小的可复制示例以及预期输出,则会更容易提供帮助。了解。