title: Performing a wilcox test in R for unpaired data
body: <p>I'm trying to use the wilcox test in R to establish if there's a significant difference between two unpaired datasets as given below. I know the data below is normally distributed but my original data is not normally distributed.</p>
  
  <pre><code>set.seed(1)
  x1 &lt;- rnorm(10, 4, 1)
  x2 &lt;- rnorm(10, 7, 1)
  
  wilcox.test(x1, x2)
  
  
  Wilcoxon rank sum test
  
  data:  x1 and x2
  W = 1, p-value = 2.165e-05
  alternative hypothesis: true location shift is not equal to 0
  </code></pre>
  
  <p>I've also tried the below code but its giving an error report</p>
  
  <pre><code>wilcox.test(x1 ~ x2)
  Error in wilcox.test.formula(x1 ~ x2) : 
  grouping factor must have exactly 2 levels
  </code></pre>
  
  <p>My question is-is this the right approach for this data?-I think its doing a rank sum test-is this what I should be getting. The p-values suggests that there is a significant difference between the two data sets. </p>