Tag: dplyr

以编程方式将类更改为自定义类

使用openxlsx软件包准备将数据openxlsx写入excel工作簿,我可以使用每列的列方式在openxlsx的小插图中运行示例来更改variables的class 。 ## data.frame to write df <- data.frame("Date" = Sys.Date()-0:4, "Logical" = c(TRUE, FALSE, TRUE, TRUE, FALSE), "Currency" = paste("$",-2:2), "Accounting" = -2:2, "hLink" = "http://cran.r-project.org/", "Percentage" = seq(-1, 1, length.out=5), "TinyNumber" = runif(5) / 1E9, stringsAsFactors = FALSE) ## Below comes the custom class assignation used for excel formatting class(df$Currency) <- "currency" class(df$Accounting) […]