0

I have a .csv file that contains 50 columns including text, numbers, amount and percentage. when I am exporting data to .xlsx in r all amount and percentage columns are converted to text. Any help?

my code below :

datafile <- choose.files("", caption = " Select files ")
data <- read.csv(datafile, header = TRUE, sep = "," )

write.xlsx(data, file = "abc.xlsx" , sheetName = "UtilizationReportGRE", row.names = F)
jacky_learns_to_code
  • 824
  • 3
  • 11
  • 29

1 Answers1

2

Write.xlsx converts factors to strings. Change your data to make the numeric columns numeric and so on before using write.xlsx. See also How to convert a data frame column to numeric type?

Aaron Parrilla
  • 522
  • 3
  • 13