View | Details | Raw Unified | Return to bug 16649
Collapse All | Expand All

(-)src/library/utils/R/object.size.R (-3 / +13 lines)
Lines 1-7 Link Here
1
#  File src/library/utils/R/object.size.R
1
#  File src/library/utils/R/object.size.R
2
#  Part of the R package, https://www.R-project.org
2
#  Part of the R package, https://www.R-project.org
3
#
3
#
4
#  Copyright (C) 1995-2013 The R Core Team
4
#  Copyright (C) 1995-2015 The R Core Team
5
#
5
#
6
#  This program is free software; you can redistribute it and/or modify
6
#  This program is free software; you can redistribute it and/or modify
7
#  it under the terms of the GNU General Public License as published by
7
#  it under the terms of the GNU General Public License as published by
Lines 23-29 Link Here
23
    function(x, units = "b", ...)
23
    function(x, units = "b", ...)
24
{
24
{
25
    units <- match.arg(units, c("b", "auto", "Kb", "Mb", "Gb",
25
    units <- match.arg(units, c("b", "auto", "Kb", "Mb", "Gb",
26
				"B", "KB", "MB", "GB"))
26
				"B", "KB", "MB", "GB",
27
                                "KiB", "MiB", "GiB", "TiB",
28
                                "PiB", "EiB", "ZiB", "YiB"))
27
    if (units == "auto") {
29
    if (units == "auto") {
28
	if (x >= 1024^3) units <- "Gb"
30
	if (x >= 1024^3) units <- "Gb"
29
	else if (x >= 1024^2) units <- "Mb"
31
	else if (x >= 1024^2) units <- "Mb"
Lines 34-40 Link Here
34
	   "b" =, "B" = paste(x, "bytes"),
36
	   "b" =, "B" = paste(x, "bytes"),
35
	   "Kb" =, "KB" = paste(round(x/1024, 1L), "Kb"),
37
	   "Kb" =, "KB" = paste(round(x/1024, 1L), "Kb"),
36
	   "Mb" =, "MB" = paste(round(x/1024^2, 1L), "Mb"),
38
	   "Mb" =, "MB" = paste(round(x/1024^2, 1L), "Mb"),
37
	   "Gb" =, "GB" = paste(round(x/1024^3, 1L), "Gb")
39
	   "Gb" =, "GB" = paste(round(x/1024^3, 1L), "Gb"),
40
	   "KiB" = paste(round(x/1024, 1L), "KiB"),
41
	   "MiB" = paste(round(x/1024^2, 1L), "MiB"),
42
	   "GiB" = paste(round(x/1024^3, 1L), "GiB"),
43
	   "TiB" = paste(round(x/1024^4, 1L), "TiB"),
44
	   "PiB" = paste(round(x/1024^5, 1L), "PiB"),
45
	   "EiB" = paste(round(x/1024^6, 1L), "EiB"),
46
	   "ZiB" = paste(round(x/1024^7, 1L), "ZiB"),
47
	   "YiB" = paste(round(x/1024^8, 1L), "YiB")
38
	   )
48
	   )
39
}
49
}
40
50
(-)src/library/utils/man/object.size.Rd (-3 / +6 lines)
Lines 1-6 Link Here
1
% File src/library/utils/man/object.size.Rd
1
% File src/library/utils/man/object.size.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2014 R Core Team
3
% Copyright 1995-2015 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
5
6
\name{object.size}
6
\name{object.size}
Lines 23-30 Link Here
23
    printed with surrounding quotes.}
23
    printed with surrounding quotes.}
24
  \item{units}{The units to be used in printing the size.  Allowed
24
  \item{units}{The units to be used in printing the size.  Allowed
25
    values are \code{"b"}, \code{"Kb"}, \code{"Mb"}, \code{"Gb"},
25
    values are \code{"b"}, \code{"Kb"}, \code{"Mb"}, \code{"Gb"},
26
    \code{"B"}, \code{"KB"}, \code{"MB"}, \code{"GB"}, and \code{"auto"}
26
    \code{"B"}, \code{"KB"}, \code{"MB"}, \code{"GB"},
27
    (see \sQuote{Details}).  Can be abbreviated.} 
27
    \code{"KiB"}, \code{"MiB"}, \code{"GiB"}, \code{"TiB"},
28
    \code{"PiB"}, \code{"EiB"}, \code{"ZiB"}, \code{"YiB"},
29
    and \code{"auto"}
30
    (see \sQuote{Details}).  Can be abbreviated.}
28
  \item{\dots}{Arguments to be passed to or from other methods.}
31
  \item{\dots}{Arguments to be passed to or from other methods.}
29
}
32
}
30
\details{
33
\details{

Return to bug 16649