title: How to divide the dataset into different groups and generate a variable with the group name
body: <p>I have created a dataset of 10.000 observations with 2 randomly generated variables. Now, I want to divide these 10.000 observations into 100 groups and generate a variable with the <code>group_number</code> and <code>group_id</code>.</p>
  
  <p>What I have done so far- </p>
  
  <pre><code>csize = 100  # number of clusters
  n = 10000    # number of observations in each cluster 
  p = 2        # number of variables 
  
  # Generating matrix with 100 normally distributed values for each p
  set.seed(1)
  mydata = matrix(rnorm(n*p, mean=0, sd = 1), n, p)   
  </code></pre>
  
  <p>Now, I want to divide these observations into 100 clusters (each cluster having 100 observations), then add two variables: <code>cluster_name</code> and <code>group_id</code>. Under the variable <code>cluster_name</code>, I would like to put on <code>cluster_1, ..., cluster_100</code>, and within each cluster, I would like to generate <code>group_id</code> for the observations. </p>
  
  <p>Thanks in advance for your kind help. </p>