[R] Adding Two-Headed Arrow in map legend

Miluji Sb milujisb at gmail.com
Sat Apr 9 17:13:54 CEST 2016


Forgot to copy the list

Dear Jim,

Thank you for your reply. I must be doing something wrong, If this is my
command to plot a map of Europe:

eps_europe <- mapCountryData(n, nameColumnToPlot="eps_score", mapTitle="EPS
Score - Europe",colourPalette=colourPalette,
                             catMethod="fixedWidth", missingCountryCol =
"white", mapRegion="Europe", addLegend=FALSE)

The following command does not seem to add the arrow. What am I doing wrong?

do.call(addMapLegend, c(eps_europe, legendLabels="none",
arrows(-100,-140,100,-140,code=3)))

Thank you again. I really appreciate it.

Sincerely,

Milu

On Sat, Apr 9, 2016 at 12:20 PM, Jim Lemon <drjimlemon at gmail.com> wrote:

> Hi Miluji,
> Try this:
>
> arrows(-100,-140,100,-140,code=3)
>
> Jim
>
>
> On Fri, Apr 8, 2016 at 10:24 PM, Miluji Sb <milujisb at gmail.com> wrote:
> > I am trying to draw maps for the world using:
> >
> > library(rworldmap)
> > library(maptools)
> > library(RColorBrewer)
> >
> >
> > tmp2<- dput(head(pece,10))
> > structure(list(iso3 = c("AUS", "AUT", "BEL", "CAN", "CHE", "CHL",
> > "CZE", "DEU", "DNK", "ESP"), eps_score = c(0.877343773841858,
> > 2.68984365463257, 1.31406247615814, 1.98046875, 2.61666655540466,
> > NA, 1.44414067268372, 2.34257817268372, 2.89687490463257,
> 2.15937495231628
> > ), gov_eff = c(1.76499999562899, 1.85666667421659, 1.74500000476837,
> > 1.88416666785876, 1.99181815710935, 1.21499997377396, 0.865833342075348,
> > 1.64999999602636, 2.15416664878527, 1.36833332975705), sh_va_enint =
> > c(13.4375638961792,
> > 8.90904521942139, 10.368335723877, 14.0469560623169, NA, NA,
> > 13.5679216384888, 9.67090892791748, 10.5978908538818, 8.34146690368652
> > ), rd_in_va = c(2.17547988891602, 2.47147130966187, 2.53955459594727,
> > 2.01138758659363, NA, NA, 1.49587619304657, 2.72330951690674,
> > 2.5316367149353, 1.48551619052887)), datalabel = "", time.stamp = " 9 Mar
> > 2016 17:43", .Names = c("iso3",
> > "eps_score", "gov_eff", "sh_va_enint", "rd_in_va"), formats = c("%9s",
> > "%8.0g", "%10.0g", "%9.0g", "%9.0g"), types = c(6L, 254L, 255L,
> > 254L, 254L), val.labels = c("", "", "", "", ""), var.labels = c("",
> > "(mean) eps_score", "(mean) gov_eff", "(mean) sh_va_enint", "(mean)
> > rd_in_va"
> > ), expansion.fields = list(c("_dta", "ReS_i", "countrycode"),
> >     c("_dta", "ReS_ver", "v.2"), c("_dta", "ReS_j", "year"),
> >     c("_dta", "ReS_str", "0"), c("_dta", "ReS_Xij", "a_"), c("_dta",
> >     "__JVarLab", "ACT"), c("_dta", "__XijVarLabrdd_", "(sum) rdd"
> >     ), c("_dta", "__XijVarLabp", "Value"), c("_dta", "__XijVarLabpop",
> >     "Population"), c("_dta", "__XijVarLabest_lu_f", "Source of lu"
> >     ), c("_dta", "__XijVarLablu", "Percentage of No Schooling"
> >     ), c("_dta", "__XijVarLabest_lp_f", "Source of lp"), c("_dta",
> >     "__XijVarLablp", "Percentage of Primary"), c("_dta", "__XijVarLablh",
> >     "Percentage of Tertiary"), c("_dta", "__XijVarLabest_lh_f",
> >     "Source of lh"), c("_dta", "__XijVarLabls", "Percentage of Secondary"
> >     ), c("_dta", "__XijVarLabest_ls_f", "Source of ls"), c("_dta",
> >     "__XijVarLabvalue", "Value"), c("_dta", "_TStvar", "year"
> >     ), c("_dta", "_TSpanel", "id2"), c("_dta", "_TSdelta",
> > "+1.0000000000000X+000"
> >     ), c("_dta", "_TSitrvl", "1"), c("_dta", "tis", "year"),
> >     c("_dta", "iis", "id2")), version = 12L, row.names = c("1",
> > "2", "3", "4", "5", "6", "7", "8", "9", "10"), class = "data.frame")
> > n <- joinCountryData2Map(pece, joinCode="ISO3", nameJoinColumn="iso3")
> > n <- n[-which(row.names(n)=='Antarctica'),]
> >
> > # EPS
> > colourPalette <- rev(brewer.pal(7, "RdYlGn"))
> >
> > eps <- mapCountryData(n, nameColumnToPlot="eps_score", mapTitle="EPS
> > Score",colourPalette=colourPalette,
> >                       catMethod="fixedWidth", missingCountryCol =
> "white",
> > addLegend=FALSE)
> > do.call(addMapLegend, c(eps, legendLabels="all", legendWidth=0.5))
> >
> > Instead of adding numeric based legend, I would like to add a two-headed
> > arrow with some text. I would be grateful for any help. Thank you!
> >
> > Sincerely,
> >
> > Milu
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list