title: Error: unused arguments in ifelse in R
body: <p>I tried to discretise a column in dataframe df using ifelse statements using the following code. The column aar contains decimal values from 0 to 12 and NAs. I check if the numeric value and assign it to the categories as below.</p>
  
  <pre><code>&gt; df= df%&gt;% mutate(arr2= ifelse( grepl("NA", aar)==T, "NA",
  &gt; ifelse(as.numeric(aar)==0, "0-0.99", ifelse(as.numeric(aar))==1,
  &gt; "1-1.99", ifelse(as.numeric(aar)==2, "2-2.99",
  &gt; ifelse(as.numeric(aar)==3, "3-3.99", ifelse(as.numeric(aar)==4,
  &gt; "4-4.99", ifelse(as.numeric(aar)==5, "5-5.99",
  &gt; ifelse(as.numeric(aar)==6, "6-6.99", ifelse(as.numeric(aar)==7,
  &gt; "7-7.99", ifelse(as.numeric(aar)==8,
  &gt; "8-8.99",ifelse(as.numeric(aar)==9, "9-9.99",
  &gt; ifelse(as.numeric(aar)==10, "10-10.99",  ifelse(as.numeric(aar)==11,
  &gt; "11-11.99", "12" )))))))))))))
  </code></pre>
  
  <p>But I get the following error, </p>
  
  <pre><code>Error: unused arguments ("1-1.99", ifelse(as.numeric(c("0", "NA", "0",...... 
  </code></pre>
  
  <p>What am I doing wrong? Can anyone kindly help me to fix this please?</p>