From 8115050159e686bab03a20766f25e0cee6f38bb6 Mon Sep 17 00:00:00 2001 From: mtennekes Date: Mon, 28 Mar 2016 21:41:31 +0200 Subject: [PATCH] CRAN VERSION 2.4-1 --- build.R | 19 --- build.bash | 16 -- build.bat | 13 -- build/build_GNI_data.R | 36 +++++ build/roxygen.r | 18 --- examples/treemap.R | 4 +- pkg/DESCRIPTION | 6 +- pkg/NEWS | 4 + pkg/R/datasets.R | 15 +- pkg/R/pkg.R | 9 -- pkg/R/treemap.R | 20 +-- pkg/data/GNI2010.rda | Bin 4079 -> 0 bytes pkg/data/GNI2014.rda | Bin 0 -> 3552 bytes pkg/man/GNI2010.Rd | 12 -- pkg/man/GNI2014.Rd | 16 ++ pkg/man/business.Rd | 2 +- pkg/man/treemap-package.Rd | 11 +- pkg/man/treemap.Rd | 4 +- .../treemap_color_palettes_mapping.html | 151 ------------------ 19 files changed, 85 insertions(+), 271 deletions(-) delete mode 100644 build.R delete mode 100644 build.bash delete mode 100644 build.bat create mode 100644 build/build_GNI_data.R delete mode 100644 build/roxygen.r delete mode 100644 pkg/data/GNI2010.rda create mode 100644 pkg/data/GNI2014.rda delete mode 100644 pkg/man/GNI2010.Rd create mode 100644 pkg/man/GNI2014.Rd delete mode 100644 pkg/vignettes/treemap_color_palettes_mapping.html diff --git a/build.R b/build.R deleted file mode 100644 index 47db089..0000000 --- a/build.R +++ /dev/null @@ -1,19 +0,0 @@ -require(devtools) - -## Create palletes, vignette and documentation... - - -setwd("../build") -source("roxygen.R") -setwd("../pkg") - - -install(".") - - -## check -check(doc_clean=FALSE) - -unlink( '../output', TRUE) -dir.create("../output", showWarnings=FALSE) -build(path= "../output") diff --git a/build.bash b/build.bash deleted file mode 100644 index ece0306..0000000 --- a/build.bash +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - - -echo "Removing building information..." -rm -rf output - -echo "Generate documentation..." -R -q -f build/roxygen.R - -mkdir output -cd output -R CMD build ../pkg -for x in *.tar.gz -do - R CMD check $x -done diff --git a/build.bat b/build.bat deleted file mode 100644 index da708e4..0000000 --- a/build.bat +++ /dev/null @@ -1,13 +0,0 @@ -@echo off - - -echo Removing building information... -rm -rf output - -echo Build documentation... -R -q -f build/roxygen.R - -md output -cd output -R CMD build ../pkg -FOR %%1 in (*.tar.gz) DO R CMD check %%1 diff --git a/build/build_GNI_data.R b/build/build_GNI_data.R new file mode 100644 index 0000000..75ef1ff --- /dev/null +++ b/build/build_GNI_data.R @@ -0,0 +1,36 @@ +library(tmap) + +## load world country data + +download.file("http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/cultural/ne_50m_admin_0_countries_lakes.zip", "./build/ne_50m_admin_0_countries_lakes.zip") +unzip("./build/ne_50m_admin_0_countries_lakes.zip", exdir="./build") +world50 <- read_shape("./build/ne_50m_admin_0_countries_lakes.shp") + +## load worlbank GNI data +#http://data.worldbank.org/data-catalog/GNI-per-capita-Atlas-and-PPP-table + + +x <- read.csv("build/GNIPC.csv", skip=7, header = FALSE, stringsAsFactors = FALSE) + +x <- x[!is.na(x[[1]]) & !x[[4]]=="" & !x[[5]] %in% c("", "..", letters), c(1,4,5)] +x <- x[1:(which(x[[1]]=="WLD")-1), ] +names(x) <- c("iso3", "country", "GNI") +x$GNI <- as.integer(gsub(",", "", x$GNI, fixed=TRUE)) +x[!x$iso3 %in% world50$iso_a3,] +x$iso3[x$iso3=="ROM"] <- "ROU" +x$iso3[x$iso3=="ZAR"] <- "COD" + +GNI2014 <- cbind(x, world50@data[match(x$iso3, world50$iso_a3), c("continent", "pop_est")])[c("iso3", "country", "continent", "pop_est", "GNI")] +names(GNI2014)[4] <- "population" + +ids <- which(!GNI2014$iso3 %in% world50$iso_a3) +GNI2014[ids, ] + +# retrieved from Wiki on 2015-03-25 +GNI2014$continent[ids] <- c("Europe", "Oceania", "Europe", "Asia", "Asia") +GNI2014$population[ids] <- c(79218 , 10640 , 1859203, 4550368 , 1201542) + +grep("I_WAS_NOT_ASCII", iconv(GNI2014$country, "latin1", "ASCII", sub="I_WAS_NOT_ASCII")) +GNI2014$country[c(145, 149)] <- c("Sao Tome and Principe", "Cote d'Ivoire") + +save(GNI2014, file = "./pkg/data/GNI2014.rda", compress = "xz") diff --git a/build/roxygen.r b/build/roxygen.r deleted file mode 100644 index eea519c..0000000 --- a/build/roxygen.r +++ /dev/null @@ -1,18 +0,0 @@ -## create documentation -require(roxygen2) -options(error=traceback) - - -unlink( '../pkg/man', TRUE) - -setwd('../pkg') - - - -roxygenize( '.' - , roxygen.dir='.' - , copy.package=FALSE - , unlink.target=TRUE -) - -setwd('../build') \ No newline at end of file diff --git a/examples/treemap.R b/examples/treemap.R index 29ff1cb..267c87f 100644 --- a/examples/treemap.R +++ b/examples/treemap.R @@ -1,8 +1,8 @@ ######################################### ### quick example with Gross National Income data ######################################### -data(GNI2010) -treemap(GNI2010, +data(GNI2014) +treemap(GNI2014, index=c("continent", "iso3"), vSize="population", vColor="GNI", diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION index 1e73af2..8d6762f 100644 --- a/pkg/DESCRIPTION +++ b/pkg/DESCRIPTION @@ -1,14 +1,16 @@ Package: treemap Type: Package Title: Treemap Visualization -Version: 2.4 -Date: 2015-10-14 +Version: 2.4-1 +Date: 2016-03-26 Author: Martijn Tennekes Maintainer: Martijn Tennekes Description: A treemap is a space-filling visualization of hierarchical structures. This package offers great flexibility to draw treemaps. License: GPL-3 LazyLoad: yes +Depends: + R (>= 2.10) Imports: colorspace, data.table (>= 1.8.8), diff --git a/pkg/NEWS b/pkg/NEWS index c9b446d..809ff8b 100644 --- a/pkg/NEWS +++ b/pkg/NEWS @@ -1,3 +1,7 @@ +version 2.4-1 +- fixed bug related to sortID +- updated GNI data + version 2.4 - added mapping argument to support manual palette mappings (see new vignette) - added standard error aggregations diff --git a/pkg/R/datasets.R b/pkg/R/datasets.R index fe7453c..0909d4e 100644 --- a/pkg/R/datasets.R +++ b/pkg/R/datasets.R @@ -5,14 +5,17 @@ #' @name business #' @references #' \href{http://en.wikipedia.org/wiki/Statistical_Classification_of_Economic_Activities_in_the_European_Community}{Statistical Classification of Economic Activities in the European Community (NACE)} -#' \href{http://epp.eurostat.ec.europa.eu/portal/page/portal/european_business/introduction}{Eurostat - Structural business statistics (SBS)} +#' \href{http://ec.europa.eu/eurostat/web/structural-business-statistics}{Eurostat - Structural business statistics (SBS)} {} -#' GNI 2010 Data +#' GNI 2014 Data #' -#' Gross national income (per capita) in dollars per country in 2010. +#' Gross national income (per capita) in dollars and population totals per country in 2014. +#' +#' The GNI numbers from the World Bank are based on the Atlas. The population data are taken from Natural Earth Data. #' -#' @name GNI2010 +#' @name GNI2014 #' @references -#' \href{http://data.worldbank.org/data-catalog/health-nutrition-and-population-statistics}{Website of The World Bank - Health Nutrition and Population Statistics} -{} \ No newline at end of file +#' \href{http://data.worldbank.org/data-catalog/GNI-per-capita-Atlas-and-PPP-table}{The World Bank - GNI per capita ranking} +#' \href{http://www.naturalearthdata.com/}{Natural Earth Data} +{} diff --git a/pkg/R/pkg.R b/pkg/R/pkg.R index 8d39c4a..acf7abe 100644 --- a/pkg/R/pkg.R +++ b/pkg/R/pkg.R @@ -1,14 +1,5 @@ #' Treemap package #' -#' \tabular{ll}{ -#' Package: \tab treemap\cr -#' Type: \tab Package\cr -#' Version: \tab 2.4\cr -#' Date: \tab 2015-10-14\cr -#' License: \tab GPL-3\cr -#' LazyLoad: \tab yes\cr -#' } -#' #' A treemap is a space-filling visualization of hierarchical structures. This package offers great flexibility to draw treemaps. #' #' The main function is \code{\link{treemap}}. See also \code{\link{itreemap}} for a graphical user interface to create treemaps. By default Tree Colors are used, which are colors from the HCL color space. Use \code{\link{treecolors}} to experiment with the parameter settings. diff --git a/pkg/R/treemap.R b/pkg/R/treemap.R index 096edcf..04c3dec 100644 --- a/pkg/R/treemap.R +++ b/pkg/R/treemap.R @@ -255,16 +255,16 @@ treemap <- } if (is.na(title.legend[1])) { - options(warn=-1) - if (!is.null(vColor)) { - if (type=="dens") - title.legend <- formatColorTitle(var=vColor, var2=vSize, - var2X=vColorX, div=vColorDiv) - else - title.legend <- formatColorTitle(var=vColor, varX=vColorX, - div=vColorDiv) - } else title.legend <- "" - options(warn=0) + suppressWarnings({ + if (!is.null(vColor)) { + if (type=="dens") + title.legend <- formatColorTitle(var=vColor, var2=vSize, + var2X=vColorX, div=vColorDiv) + else + title.legend <- formatColorTitle(var=vColor, varX=vColorX, + div=vColorDiv) + } else title.legend <- "" + }) } # algorithm diff --git a/pkg/data/GNI2010.rda b/pkg/data/GNI2010.rda deleted file mode 100644 index cf3a7c64f32a6b8affbb1ef4bd64772740fbf0b9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4079 zcmVBN91?T}CesiEd&* z*{Z`lf7bJ#lVW*ID7+cTp*WK9Q6y7g zBy%w$X>Tr#q(Wq#HWU;h^GHr0vv4$lWGqEw2FalilJO{!IV6WYBuWb>hLKFshSUU- z=>n3YBsfRXa$zD#ojj47ac?9vL?mvA49AE}5lI^oV@Re^$;fD&NIEu({*7emSPtD6 zDTIl{z(&UD*mxF63P3c5eu$1BvuGM^i)NBYk`B=c+z^W(hgf_ZNzyE)WQoKih~+Ut zLkV=r5a}>Pu^7r>P7YC?#Y1RuJdEy($8c|a7&*ifw3npC(=?m$keiUqMTm?NiD8N7 zNu7d+L_Z8CF`B~}~Px5<(?M zMsdSP7MUeOSRzTP!epFghmk`vfgF+<6pMdL(bu+lLUk*1PPCow|lRDwt}K26n~ z&cui$5g9Cz^eDPIog)s^NYk51#5m24vMFp#Su#FLT`o&qBby_>=zJPwn(;ZNtj4C8?Z-IhU zP-w#hI%+I}aT}vpj8R(|%b=2D^nTb(cffcI$qB0N3F_+;+^PO|PjASyi%bkI32m!X znXWZ0ri-b*kX|ur?uKBfR^;pM@QQ-2S!!7dnXD+q>YB+cwJFvHLS{wPElsDhW?iMT zmxk)9sg;;6DXea|vmXobBNdxTOfO4eW)|%-Lxy(KGFeR{hV2O)4u)n_v&gg?QTJfj zHf_DE;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8f2+LeK9A`<{CU(3%tDtbhN$fAEi|CBVBxT<;M6dFPy?i2Q41 ztAjVs1(y2AJ4IeTBkryJB7fa`Rrpoj1$xNG;NFu@4Eg!I0u55$EiWzSFg&2;S^qlb z+0I44H+O>GJB56=?jG{zHJ(54TmM+}4;-H~0Z&7}lHZ*IJs)_>zwd<)0C(TypTBi0 zpzxnOFYdM5#rmTnulGCwctU)i5all)7WdwM@gAHNcHSb^A8d$yzX5#bQ=s22!T;bq z;L#s+*eL=2qtNR?k*9YGd`i3-p?Oz8r1Mr)dUiT}O)-_+r|$+{BUEZI;9$G hy6U)-gJov1&u=r^zqkwp+Ts4~{{iI4`Wk>S003afC5!+7 diff --git a/pkg/data/GNI2014.rda b/pkg/data/GNI2014.rda new file mode 100644 index 0000000000000000000000000000000000000000..29904e4f2e7feb3a124634c1be19d6278c5bf24d GIT binary patch literal 3552 zcmV<64IlFTH+ooF0004LBHlIv03iV!0000G&sfahB|#0MT>vQ&2UJ%gRpOV<& z?GPy~bf#WPY3<0CZwuB>MH(jURp%T3pScgQA>_A1;R2XTc8=_+@A{_*-LxgSKX7oK z?^c^Z{esstX7-mXuPU+CdtMUHp})Dt;?v9y)K^dxcaJm^_T>jshgpl==_UlldSP(mmzEBHN4z%{U{`;sNH8&{-+iyJG#*pC)8qvAtb!H58 zL;hnDP}8PRw@FHM5g@u_M+#W?>^wJ}c4YQCvNQqAl?ETfk=61xH`u}$UnxJ*^|U6p z`)8bb& zSF4qBmZwO-+sKV?JJr75=XbP?ELeQ)^@_30p=u+>A^O7}2p;Zz74*vG*Ye|lS@%DT zt*f$XC~#nVRw7?zvr28=0m}jLjPaSt!2nwSZo}Z@nBnGB}e{d+6 zZexP3aHk-QS3&b6&;$Lyo1#v~O=A3fp?OaUBFGOw#n%Pgx^i)h5r*DW?^Fl|8^NPx zm4thsqfu1iR(-G>?!FPJ3uhG|RFOLNPt-^(uYYLtWP7pZtxibizZcg8{2R_A+9V?{U3Mh|8cLuZz4vksuv{ z#x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`hG% zi;=W4l2B$2vSF8hD%&whFP2tYR4rS5Rvt( zklYPP%{8MDbK=@rI*`GT!ifn2vTUh#0GNT7Cy`#vlPh61eABf@`7&B?5; z(hl$OX3LH6YDJ$=vc#93w4~|Q-s*-SuMNhQufPHoo}gl1#BYe56`HbDVE5o01Hiso z3Efl1^>>`KUbRP~4pM7Lkhcxjy$-Oh=z`eomf`Hv_ycd-`ZlvrUR4xW)ZpYKI=K%r zAvp=+BZCJp4yEba#aZH{d@nCZp6NB>?7;^H-DV{{4c9-^Q9=j~kt5|zH?L-Yx08V? z_6$Ti`i}tlNLGz*5fdN_qT|{?XUaU*-BcWm8F+v9$^sQ8=={od-FE2_JU)%;&lWR3 zpGAC} z*rOH{Frxx&^hbh{kL%rN3 z8L*t~8tewCqm*SkK0t{NFaem8IL=9NqP*jNWvOR6iQw*oYw`9qxt~5i9*Iu9HtWC+ zQEI|n^^~5GV-Ekb>G(ze6RrxoA1BI@s3Ee2LUA*x7>p`25yCLgTXKU=j-H#*JcDig zF~5!E3RO)*7{vQjy6{AD+hdCg9GWwRv+g(Rd4L7M zi^N2ZI0hZl}dF5$P0SP}~pu7Fl+nEu17XdO;agc^o*7T;itI zj)zD}&D#(Kt4~lgEbdWx+f)rGC-la;vEA&m>a)=C{;0I7$2NU2leTJSc@ zSo@_NGt74gou_Dv28EKbyiVXAzX_=-#pLO@K*7m!K>ZUWeb4w&F4_+`%Hr`&K?1`A zq2>@ZgntjTj`j3TGL5j|&`IgM6YoJ1P#G zb6RwvS!czdTwfX&=sgWEkl9Th!cw8>E(EW7ABO;`U(}|KjVd+d@rSgyGedk zGx3&n;|ME89;Si5>U&nq6vK%4B6VNB^RSr-g+oG - - - - - - - - - - - - - -treemap: mapping to color palettes - - - - - - - - - - - - - - - - - - - - - -
- - - - - -

This small tutorial is about the mapping of values to color palettes, for treemap types “value” and “manual”.

-

There are to arguments that determine the mapping to color palettes: mapping and palette. The arguent range does not influence this mapping, as it only defined what range of color values is shown in the legend.

-

The only difference between “value” and “manual” is the default value for mapping. The “value” treemap considers palette to be a diverging color palette (say ColorBrewer’s "RdYlBu"), and maps it in such a way that 0 corresponds to the middle color (typically white or yellow), -max(abs(values)) to the left-end color, and max(abs(values)), to the right-end color. The “manual” treemap simply maps min(values) to the left-end color, max(values) to the right-end color, and mean(range(values)) to the middle color.

-
library(treemap)
-set.seed(20151014)
-
-

“value” type treemaps: mapping=(-max(abs(values)), 0, max(abs(values)))

-
dat1 <- data.frame(letters=letters[1:26], x=1, y=runif(26)*16-8)
-treemap(dat1, index="letters", vSize="x", vColor="y", type="value", palette="RdYlBu")
-

-

You see that the center color (Yl) will automatically be assigned to 0, negative values to Rd-Yl and positive to Yl-Bu:

-

Example when there are more extreme negative values than positive:

-
dat2 <- data.frame(letters=letters[1:26], x=1, y=runif(26)*16-12)
-treemap(dat2, index="letters", vSize="x", vColor="y", type="value", palette="RdYlBu")
-

-

The reason why you see only -10 to 2 in the legend (and not -10 to 10), is because the range argument is by default c(min(values), max(values)) with a pretty rounding. This can be changed of course:

-
treemap(dat2, index="letters", vSize="x", vColor="y", type="value", palette="RdYlBu", range=c(-10,10))
-
## Warning in value2col(datlist, position.legend, palette, range, mapping, :
-## Values are found that exceed the provided range
-

-

If there are only positive values, only the Yl-Bu half is used:

-
dat3 <- data.frame(letters=letters[1:26], x=1, y=runif(26)*16)
-treemap(dat3, index="letters", vSize="x", vColor="y", type="value", palette="RdYlBu")
-

-
-
-

“manual” type treemaps: mapping=(min(values), 0, max(values))

-

Let’s rerun the examples for type="manual":

-
treemap(dat1, index="letters", vSize="x", vColor="y", type="manual", palette="RdYlBu")
-

-

This is essentially the same treemap as above, because the middle value 0 for “value” is very close to mean(range(dat1$y)) which is -0.045.

-
treemap(dat2, index="letters", vSize="x", vColor="y", type="manual", palette="RdYlBu")
-

-

In this case, yellow will be assigned to the middle value mean(range(dat2$y)) which is -3.89.

-
treemap(dat3, index="letters", vSize="x", vColor="y", type="manual", palette="RdYlBu")
-

-

In contrary to value treemaps, also the lefthand-side range of the diverging palette is used when there are only positive values.

-
-
-

treemaps with custom mapping

-
treemap(dat1, index="letters", vSize="x", vColor="y", type="value", palette="RdYlBu", mapping=c(-20, 0, 20))
-

-

This is an interesting one. Now -20 and 20 are mapped to both ends of the palette. What you get, is that the middle color is still 0 (as with value), but the colors range from orange to light blue, because only middle part of the palette is used.

-

You don’t see -20 and 20 in the legend, because range is by default c(min(values), max(values)) with a pretty rounding. You can change this, of course:

-
treemap(dat1, index="letters", vSize="x", vColor="y", type="value", palette="RdYlBu", mapping=c(-20, 0, 20), range=c(-20,20))
-

-

If range falls outside the mapping, the correspinding legend items will be assigned to the end colors of the palette:

-
treemap(dat1, index="letters", vSize="x", vColor="y", type="value", palette="RdYlBu", mapping=c(-20, 0, 20), range=c(-40,40))
-

-

Suppose we want the range of data values to be mapped to the whole palette, with 0 as middle value:

-
treemap(dat2, index="letters", vSize="x", vColor="y", type="value", palette="RdYlBu", mapping=c(min(dat2$y), 0, max(dat2$y)))
-

-

Let’s assign 10 to the middle value:

-
treemap(dat3, index="letters", vSize="x", vColor="y", type="value", palette="RdYlBu", mapping=c(0, 10, 20))
-

-
- - -
- - - - - - - -