I have vector/table y which I generated using:
y <- (x/rowSums(x))*100
Then, I aimed to output the variable y into excel file (goal is to append multiple files)
write.xlsx(y, file="Test.xlsx", asTable=TRUE, sheetName="Distribution", append=F) #Append =F as this is first sheet
The excel fiel Test.xlsx however has the data in 2 columns
I figured that write.xlsx can't handle vector format, so I used cbind(y) to convert to matrix. While this worked, I lost the column names. Thus, was unsuccessful in retrieving.
I think there is an easy fix but I couldn't find it. So, how can I output a vector table Tinto write.xlsx without losing data?
Thanks