I have a dataframe object made from a loop foreach(..., .combine= rbind). After naming its columns, I save it in a .dbf file thanks to the write.dbf function. But when I open the matching file in LibreOffice Calc my colunms' names have changed and some ",N,19,9", ",N,5,0" or ",N,19,10" (etc) have been appended to them.
I'm working on a Linux Fedora machine and with RStudio.
> c("ID","X","Y",unlist(LU_Named),paste(animalUsed,"_p",sep=""),"Alti_me20","Alti_ra20","Slope_me20","Slope_ra20")
> print(names(datF_output))
> write.dbf(datF_output, paste(Base2OutPath,"rANIMALS",sep = "/"), factor2char = FALSE, max_nchar = 254)
The print(namesdatF_output)) gives me the correct names :
[1] "ID" "X" "Y" "broad_AR" "conif_AR"
[6] "arable_AR" "imprg_AR" "rough_AR" "neutrg_AR" "calcg_AR"
[11] "acidg_AR" "fen_AR" "heath_AR" "heathg_AR" "bog_AR"
[16] "monta_AR" "inroc_AR" "saltwat_AR" "freshw_AR" "slitro_AR"
[21] "slitse_AR" "litroc_AR" "litsed_AR" "saltma_AR" "urban_AR"
[26] "suburb_AR" "Sheep_2003_p" "Alti_me20" "Alti_ra20" "Slope_me20"
[31] "Slope_ra20"
but the names in my file are :
ID,N,5,0 X,N,19,10 Y,N,19,9 broad_AR,N,19,9 conif_AR,N,19,9 arable_AR,N,19,9 imprg_AR,N,19,9 rough_AR,N,19,10 neutrg_AR,N,19,10 calcg_AR,N,19,9 acidg_AR,N,19,10 fen_AR,N,19,11 heath_AR,N,19,9 heathg_AR,N,19,11 bog_AR,N,19,9 monta_AR,N,19,10 inroc_AR,N,19,9 saltwat_AR,N,19,10 freshw_AR,N,19,9 slitro_AR,N,19,10 slitse_AR,N,19,10 litroc_AR,N,19,15 litsed_AR,N,19,11 saltma_AR,N,19,9 urban_AR,N,19,10 suburb_AR,N,19,11 Sheep_2003,N,19,13 Alti_me20,N,19,13 Alti_ra20,N,19,13 Slope_me20,N,19,14 Slope_ra20,N,19,14
write.dbf() changes my dataframe columns' names
No, it doesn't; it's just that LibreOffice/OpenOffice handles DBF files in a way where additional information (field type, width and decimals) is appended to the name, cf. Importing and Exporting dBASE Files (… do not alter or delete the first row in the imported file. This row contains information that is required by a dBASE database) and Connecting dBase (xBase). Side note: Excel doesn't display that information.