dataframe - R error when using write.xlsx with an object created with functions of 'dplyr' -
i´m having problem when trying write data frame excel file using function write.xlsx
xlsx
package. though problem appears when data frame created functions dplyr
package. when use base functions, there no problem. below minimal example.
first, sample data:
library(dplyr) library(xlsx) month <- c('julio','diciembre','diciembre','agosto','noviembre', 'diciembre', 'junio','septiembre','agosto','julio') irrelevant_column <- rep(1,10) df <- as.data.frame(cbind(irrelevant_column, month))
as said, when use base functions there no problem:
month1 <- table(df$month, df$irrelevant_column) month1 <- prop.table(month1 , 2) month1 <- as.data.frame.matrix(month1 ) write.xlsx(month1 , file="month1.xlsx")
no error appears, when create similar data frame 'dplyr':
month2<- count(df, month) month2<- mutate(month2, porc = n / sum(month2[, 2])) month2<- as.data.frame.matrix(month2) write.xlsx(month2, file="month2.xlsx")
the following error message appears:
error in .jcall(cell, "v", "setcellvalue", value) : method setcellvalue signature ([ljava/lang/string;)v not found in addition: warning message: in if (is.na(value)) { : condition has length > 1 , first element used
is there solution this, or xlsx
not compatible dplyr
?
Comments
Post a Comment