'decimal point problem in integer, Delete unnecessary decimal points when reading and writing Excel files

I used function

#1)
df<-read_excel(excelfile.xlsx, col_types='text')
#2)
df<-read_excel(excelfile.xlsx) %>% mutate_it(is.numeric, as.character)

df %>% openxlsx::write.xlsx('result.xlsx')

In both cases, integers have unnecessary decimal points. for example, original excelfile.xlsx have 1, 2, 3 but result.xlsx have 1.0,2.0,3.0

I want that result have 1, 2, 3

how to solve this problem?

and

The reason I converted a number to a character is because I got an error when I used bind_rows with another df.

Can't combine `..1$A` <character> and `..2$A` <double>.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source