Basic data was generated using a SQL query and the intention is to process data in R. However, while importing from a .csv or from .xlsx, R imports numbers as characters in spite of changing the data-type in the built-in import tool. Further, while performing basic arithmetic operations, following errors were encountered:
 In Ops.factor((data$A), (data$B)) :‘/’ not meaningful for factors
Is there a simple way to solve this?
- Data-set was analysed using the str()function, which revealed that R imported the particular columns asfactors.
- Used package varhandleand functionunfactorto unfactorize the data
- Used as.numericfor some columns which were read ascharactersinstead offactors
- Tried changing data-types in Excel before importing - data$A <- unfactor(data$A)- data$B <- unfactor(data$B)- data$PERCENTAGE <- (data$B)/(data$A)*100
By what means can R import the data as per specified data-types?
Thank you for the help in advance!
 
    