title: R Language : Convert Categorical to numeric
body: <p>**Hello every one , i am new to R Language and i am trying convert data from categorical to numeric , i read Database.csv and i made all opeartions but i face Error in results and code not run ,
  Error "error-in-r-arguments-imply-differing-number-of-rows-4 7"</p>
  
  <p>Note : My data base consists of one row only and i tried on other database consist of from multi rows and all operations successed .</p>
  
  <p>this is my database and below my Code .
  <a href="https://my.pcloud.com/publink/show?code=XZbbjNZoNfJRmssXnSj8tQq6qjOyJayKwyX" rel="nofollow noreferrer">https://my.pcloud.com/publink/show?code=XZbbjNZoNfJRmssXnSj8tQq6qjOyJayKwyX</a></p>
  
  <p>any one help me please .
  **</p>
  
  <pre><code>rm(list=ls(all=TRUE))
  setwd("C:/Users/maher/Desktop/R")
  
  # Load required libraries
  library(vegan)
  library(dummies)
  library(dummy)
  library(e1071)
  attr = c('id', 'age', 'exp', 'inc', 'zip', 'family', 
       'ccavg', 'edu', 'mortgage', 'loan', 
       'securities', 'cd', 'online', 'cc')
  
  # Read the data using csv file
  data = read.csv(file = "One.csv", 
              header = TRUE, col.names = attr)
  
  # Removing the id, zip and experience. 
  drop_Attr = c("id", "zip", "exp")
  attr = setdiff(attr, drop_Attr)
  data = data[, attr]
  rm(drop_Attr)
  
  # Convert attribute to appropriate type  
  cat_Attr = c("family", "edu", "securities", 
           "cd", "online", "cc", "loan")
  num_Attr = setdiff(attr, cat_Attr)
  cat_Data &lt;- data.frame(sapply(data[,cat_Attr], as.factor))
  num_Data &lt;- data.frame(sapply(data[,num_Attr], as.numeric))
  
  data = cbind(num_Data, cat_Data)
  
  # Do the summary statistics and check for missing values and outliers.
  summary(data)
  
  #------------------------------------------------------
  
  ind_Num_Attr = num_Attr
  rm(num_Attr)
  ind_Cat_Attr = setdiff(cat_Attr, "loan")
  rm(cat_Attr)
  
  # Standardizing the numeric data
  cla_Data = decostand(data[,ind_Num_Attr], "range") 
  rm(ind_Num_Attr)
  
  # Convert all categorical attributes to numeric 
  # 1. Using dummy function, convert education and family        categorical**strong text** attributes into numeric attributes  
  edu = dummy(data.frame(data$edu))
  family = dummy(data.frame(data$family))
  cla_Data = cbind(cla_Data, edu, family)
  ind_Cat_Attr = setdiff(ind_Cat_Attr, c("edu", "family"))
  rm(edu, family)
  
  # 2. Using as.numeric function, convert remaining categorical attributes into numeric attributes 
  cla_Data = cbind(cla_Data, sapply(data[,ind_Cat_Attr], as.numeric))
  ind_Attr = names(cla_Data)
  cla_Data = cbind(cla_Data, loan=data[,"loan"]) 
  str(cla_Data)
  cla_Data &lt;- data.frame(sapply(cla_Data,as.numeric))
  summary(cla_Data)
  write.csv(cla_Data,"OneAfter.csv")
  </code></pre>