title: Create Loop for Box Plots in R
body: <p>I have a dataset that contains both numeric and categorical values. I am trying to create box plots to visually identify outliers for each numeric column in my dataset. The below code works to do this, but it is very clunky and I would not want to use this code with even more variables. I am looking for a way to use a loop to create box plots using a loop in R.</p>
  <p>Here is the clunky code that works without a loop:</p>
  <pre><code>#Using Boxplots, check for outliers in each in each float or integer value column. 
  
  b &lt;-boxplot(df$item1, main = 'item1')
  b &lt;-boxplot(df$item2, main = 'item2')
  b &lt;-boxplot(df$item3, main = 'item3')
  b &lt;-boxplot(df$item4, main = 'item4')
  b &lt;-boxplot(df$item5, main = 'item5')
  b &lt;-boxplot(df$item6, main = 'item6')
  b &lt;-boxplot(df$item7, main = 'item7')
  b &lt;-boxplot(df$item8, main = 'item8')
  b &lt;-boxplot(df$item9, main = 'item9')
  b &lt;-boxplot(df$item10, main = 'item10')
  b &lt;-boxplot(df$item11, main = 'item11')
  b &lt;-boxplot(df$item12, main = 'item12')
  b &lt;-boxplot(df$item13, main = 'item13')
  b &lt;-boxplot(df$item14, main = 'item14')
  b &lt;-boxplot(df$item15, main = 'item15')
  b &lt;-boxplot(df$item16, main = 'item16')
  </code></pre>
  <p>In python the code would be:</p>
  <pre><code>outliers = ['Item1', 'Item2', 'Item3', 'Item4', 'Item5', 'Item6', 'Item7', 'Item8', 'Item9', 'Item10', 'Item11', 'Item12', 'Item13', 'Item14', 'Item15', 'Item16']
  
  i=0 
  while i &lt; len(outliers):
      sns.boxplot(x = outliers[i], data = df)
      plt.show()
      i = i + 1
  </code></pre>
  <p>(I am looking for something similar in R!)
  Thank you!</p>