I loaded an sheet form excel in R and want to write a section of it to a new sheet, using the original column names. Firs attempt:
weekdata <- Data [ which(Data$week ==weeknr ),]
write.xlsx2(x=weekdata, file=Document,
sheetName =BLAD , row.names = FALSE, append = TRUE)
weekdata as seen in excel The data in a colum schow all in the first field as this a list: c("2020 6", "2020 6", "2020 6", "2020 6", "2020 6",...) To get the data row by row i have to set row.names=TRUE, but this ads an extra column.
Second attempt was to use the data.frame function:
weekdata <- data.frame( Data [ which(Data$week ==weeknr ),])
Now the problem is the column-names change when special symbols are used:(from "# bl" to "X..bl")
Is there a simple solution I'm unaware of?