title: Generating binary variables in Pig\R
body: <p>I am working on the design thought for generating dummy or binary variable in pig script or R script</p>
  
  <p>problem:
      Input to pig script: Any arbitrary relation say as below table </p>
  
  <pre><code>    A   B   C
      a1  b1  c1
      a2  b2  c2  
      a1  b1  c3
  </code></pre>
  
  <p>suppose we have to generate binary cols based on B,C
      output should be</p>
  
  <pre><code>    A   B   C   B.b1    B.b2    C.c1    C.c2        C.c3
      a1  b1  c1  1        0       1       0       0
      a2  b2  c2  0        1       0       1       0
      a1  b1  c3  1        0       0       0       1
  </code></pre>
  
  <p>I think writing UDF would be right approach on it. However i am not sure as how to define the output schema for the udf as the column names are supplied by the user and we dont know in the relation how many distinct cols needs to be generated.
      Could somebody please guide me as a high level design to achieve it. is it feasible to do in R do we have some online solution for this statistical problem</p>