title: How to get a value in another table in R?
body: <p>My problem is probably simple for many of you. I have a tibble that contains a list of categories with values next to them related to that category.
  I want to create a dataset from these values. For this I create a new tibble. In a column I draw one of the categories at random (function sample, replace =T). In the second column I want to add noise to the characteristic value of this category.
  My problem is to find out how to refer to the cell that is relative to this particular category in another table.</p>
  <p>Here is an exemple :</p>
  <pre><code>library(tidyverse)
  
  carac &lt;- tibble(
    class = c(&quot;raptor&quot;,&quot;valor&quot;,&quot;defender&quot;),
    weight = c(123,125,596)
  )
  
  test &lt;- tibble(
    serie = sample(carac$class,100, replace=T),
    weight = weight_of_this_class*rnorm(1,mean=1, sd=0.2)
      )
  </code></pre>
  <p>I don't know what to use instead of &quot;weight_of_this_class&quot; ? I tried carac[class], but obviously doesn't work :/</p>
  <p>What i want i a table like that :</p>
  <pre><code># A tibble: 100 x 2
     serie    weight
     &lt;chr&gt;     &lt;dbl&gt;
   1 raptor     142.5
   2 defender   660.3
   3 raptor     129.6
   4 valor      132.1
   5 defender   822.3
   6 defender   611.5
   7 valor      117.4
   8 raptor     112.7
   9 valor      150.6
  10 defender   712.6
  # ... with 90 more rows
  </code></pre>
  <p>(manually calculated data for the example of what i want, it's just &quot;123*rnorm(1,mean=1, sd=0.2)&quot; for the raptor, for example.)</p>
  <p>Thank you so much !</p>