Question: I am new to R and would like to do this if anyone can give me example, would appreciate. If I have this file :

```
Row1_id ,  val11, val12 , val13  
Row2_id ,  val21, val22 , val23

```

I need to split it to 3 files. A file for each column plus the row id and tab separated For example file1 should be:

```
row1_id val11  
row2_id val21

```

and the third file3:

```
row1_id  val13  
row2_id  val23

```

Answer: 
So it ended up being a problem with the fetch its self. The controller was in fact doing what I wanted it to but the fetch needed to be formatted like:

```
  componentDidMount() {
  fetch(`/api/v1/coffee_formulas.json`, {
    credentials: 'same-origin',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    },
    method: 'GET'
  }).then(response => response.json())
    .then(body => {
      this.setState({
        formulas: body.coffee_formulas,
        user: body.current_user
      })
    })
  } 

```
`NoMethodError (undefined method 'coffee_formulas' for nil:NilClass)` means that you are trying to invoke `coffe_formulas` method on `nil` class. Your current\_user helper returns `nil` so you haven't authorized your request.