I am very new to the language. I have read in multiple csv files as dataframes, setwd(“/Users/user/go/src/Project/outputcsv2D”) file_list <- list.files(path=”/Users/user/go/src/Project/outputcsv2D”) filenames <- gsub(“\\.csv$”,””, list.files(pattern=”\\.csv$”)) for(i in filenames){ assign(i, read.csv(paste(i, “.csv”, sep=””))) } but when I try to loop over the filenames[i] to plot, #making a list of plots plot_list = list() for (i in filenames) […]
Categories
Looping over multiple data frames to ggplot
- Post author By Full Stack
- Post date November 30, 2019
- No Comments on Looping over multiple data frames to ggplot
- Tags 'csv', "", "png", #making a list of plots plot_list = list() for (i in filenames) { p = ggplot(filenames[i], 150) plot_list[[i]] = p } # Save plots to png. Makes a separate file for each plot. for (i in filenames) { file_name = paste("2D", 150)+ylim(0, aes(y, colour = color)) + geom_point(alpha = .4)+xlim(0, i, I am very new to the language. I have read in multiple csv files as dataframes, list.files(pattern="\\.csv$")) for(i in filenames){ assign(i, not a character vector I have tried get() or as.data.frame() but neither seemed to work. What would be the solution for this problem?, or other object coercible by `fortify()`, read.csv(paste(i, sep="") png(file_name) print(plot_list[[i]]) dev.off() } it is giving me this error : Error: `data` must be a data frame, sep=""))) } but when I try to loop over the filenames[i] to plot, setwd("/Users/user/go/src/Project/outputcsv2D") file_list <- list.files(path="/Users/user/go/src/Project/outputcsv2D") filenames <- gsub("\, X