karlqi 2008年3月18日发布 #6 2008年3月18日星期二 03点43分 toString()不行的吧,试了一下只能得到"11, 22, 33" 还是用paste吧,要不就把toString改改,既然都是用paste实现的嘛! 参考: toString <- function(x, ...) UseMethod("toString") toString.default <- function(x, width = NULL, ...) { string <- paste(x, collapse=", ") if( missing(width) || is.null(width) || width == 0) return(string) if( width < 0 ) stop("'width' must be positive") if(nchar(string, type = "w") > width) { width <- max(6, width) ## Leave something! string <- paste(strtrim(string, width - 4), "....", sep = "") } string }
karlqi toString()不行的吧,试了一下只能得到"11, 22, 33" 还是用paste吧,要不就把toString改改,既然都是用paste实现的嘛! 参考: toString <- function(x, ...) UseMethod("toString") toString.default <- function(x, width = NULL, ...) { string <- paste(x, collapse=", ") if( missing(width) || is.null(width) || width == 0) return(string) if( width < 0 ) stop("'width' must be positive") if(nchar(string, type = "w") > width) { width <- max(6, width) ## Leave something! string <- paste(strtrim(string, width - 4), "....", sep = "") } string }