format.bytes = function(x) { # returns byte sizes in pretty form # example: format.bytes(c(2,1030,2e6)) round.to.half = function(x) round(x*2)/2 s = as.character(x) names(s) = names(x) kilo = 2^10; mega = 2^20 i = (x >= mega) s[i] = paste(round.to.half(x[i]/mega),"M",sep="") i = (x >= kilo) & (x < mega) s[i] = paste(round(x[i]/kilo),"k",sep="") s }