0

I tried to search in the net but I didn't find a solution (looks very simple though). I made a loop for box plot and bar plot for all the variables in a table, the received barplots are without label name, means I don't know to refer each graph for a variable. I tried with calling the boxplot(flat_file_numeric[[i]],main=i) but it didn't work. here is my code:

for (i in flat_file_numeric) {
    boxplot(i, col = rainbow(ncol(flat_file_numeric)))
}

this is one of the graph I am getting: boxplot

I appreciate your answers.

Phil
  • 7,287
  • 3
  • 36
  • 66
  • What about `boxplot(i, col = rainbow(ncol(flat_file_numeric)), main=flat_file_numeric[i], ylab=flat_file_numeric[i]$)`? There are no sample data, but `main` and `ylab` are how those components are usually labelled. https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – John Polo Feb 12 '22 at 21:27
  • Without data it is difficult to understand what you want. I imagine you wanted to loop through the columns of a dataframe. But when you do that, each iteration will return you a vector. Not an object containing the names like person you want; Look: `par(mfrow=c(1,4)); for (i in 1:ncol(iris[,-5])) boxplot(iris[,i], main=colnames(iris)[i])` – jassis Feb 12 '22 at 21:44
  • Thanks @jassis that's work great. though I don't understand the role of [] in some situations. p.s- sorry for the lack of data – Erez Kauffman Feb 13 '22 at 08:44

0 Answers0