0
 for(row in 3:11)
{ i= 0
 if(col1[row] == 0)
 {
breakfast[i] = 0
  }
  else if(col1[row] == 1)
 {
   breakfast[i] = 0.428
 }
  else{
  breakfast[i] = 0.858
 }
 i = i + 1
}

This is the code for my first column and I want to implement this in all the columns of my excel sheet. Is there any shortcut

Mahima
  • 1
  • 1
    Welcome to stack overflow. You'll find that you get more helpful responses if you make a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), and more clearly describe what you mean by shortcut. – alexwhan Jun 12 '18 at 09:53
  • You can create a `function` and `mutate`/`apply`/`lapply` etc. over all of your columns – DJV Jun 12 '18 at 11:32

0 Answers0