title: New matrix containing specific data
body: <p>Sample Data</p>
  
  <pre><code>data=data.frame("group"=c(rep(0:1,10)),
                  "value1" = c(1:10),
                  "value2" = seq(11:20),
                  "value3" = as.factor(rep(1:3,length=10)))
  </code></pre>
  
  <p>Goal
  <a href="https://i.stack.imgur.com/jHarQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jHarQ.png" alt="enter image description here"></a></p>
  
  <p>I have data frame "data" with a goal to create a new data frame as shown in the picture. PLEASE NOTE THAT VALUE3 IS A FACTOR VARIABLE. So I would want to report n and percent. For each group like in the picture.</p>
  
  <p>I know to estimate min and max separately like as follows</p>
  
  <pre><code>value1_min0 = min(data$value1)[data$group==1]
  value1_max0 = max(data$value1)[data$group==1]
  value1_min1 = min(data$value1)[data$group==0]
  value1_max1 = max(data$value1)[data$group==0]
  </code></pre>
  
  <p>But is there  a better way to do this more effectively?</p>