title: Write a function to output min, average, and max given input of values for multiple columns in R
body: <p>I have 3 variables (A, B, and C) each containing 10 values (1 values per row) and I would like to create a range (output) or three columns for each variable. Basically given the 10 values for A, B, and C, I want to automate an output that gives me the min, avg, and max value for each variable in R. I was thinking of using a function and my input being the three variables. </p>
  
  <p>I used excel but once I get more data, I will have trouble outputting the values. I used a condition statement and manually fed in the values - I would like to create three new columns corresponding to each range (Min, Avg, and Max) per variable. </p>
  
  <pre><code>#Create a DataFrame
  ## Random Matrix - Three Variables - 50 rows ##
  trial &lt;- matrix(sample(100, replace = TRUE), ncol=3)
  colnames(trial) &lt;- c('MFP', 'ECU', 'HMU')
  trial.table &lt;- as.table(trial)
  trial &lt;- as.data.frame(trial)
  
  ## Creating Min, Average, and Max range for each Column ##
  
  
  # setting blank vector to fill #
  # Create new double vector: output
  df2 &lt;- data.frame(matrix("", ncol = 3, nrow = 1)) 
  colnames(df2) &lt;- c('Min_thresh', 'Average', 'Max')
  
  
  # Alter the loop
  for (i in trial$MFP) {
    # Change code to store result in output
    df2$Min_thresh &lt;- min(trial$MFP)
    df2$Max &lt;- max(trial$MFP)
    df2$Average &lt;- mean(trial$MFP)
  }
  
  # Print output
  df2
  </code></pre>
  
  <p>Expected output would be three columns added to a blank df that shows min, average, and max values pulled from each column:</p>
  
  <pre><code>df3 &lt;- data.frame(matrix("", ncol = 3, nrow = 1)) 
  
  df3$min &lt;- min#
  df3$average &lt;- avg#
  df3$max &lt;- max #
  </code></pre>
  
  <p>I would then populate each column given the range of Min, min to avg, and then Max value... where Avg is the delta between Avg and the min (like a range with 10 being the Min and 16 being the Avg.).</p>