I am running a SQL query in R, where the MemberID column has 9 or 10 characters. When I manually copy and paste this in excel as text format, the MemberID column retains leading zero for those members who have 9 digits. But when I automate R to run script and export data to excel, it doesn't retain leading zeroes in the MemberID column. It is a numeric column and I tried changing it to a character but it doesn't work. Is there a way to keep the leading zeroes in excel?
Data <- sqlQuery(odbcChannel,
where PlanID ='AR'")
saveWorkbook(WB,file="MemberByPlan", overwrite =TRUE)