[R] Mapping code not working

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Wed Nov 19 14:27:10 CET 2014


Your error references a column that is not mentioned in your sample line of code. . suggesting that something else is going on.

The usual advice applies, as the footer always says:

>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

One thing mentioned in the Posting Guide is that you should post in plain text, since HTML format can lead to confusion on our end (what you see is not necessarily what we see). You may also find [1] helpful in clarifying what reproducible means.

[1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On November 19, 2014 3:38:47 AM PST, Chris Montgomery <c.montgomery at sheffield.ac.uk> wrote:
>I have a data frame of data I want to map. I've already created a base
>map
>called 'England'. The data frame is as follows:
>
>'data.frame':   2303 obs. of  13 variables:
> $ Response.ID: int  1 2 3 4 5 6 7 8 9 10 ...
>$ Year       : int  2013 2013 2013 2013 2013 2013 2013 2013 2013 2013
>...
> $ Sex        : Factor w/ 2 levels "f","m": 1 2 1 1 1 1 2 2 2 2 ...
>$ Ethnicity  : Factor w/ 6 levels "","Black","East Asian",..: 6 6 6 6 6
>6
>6 6 6 6 ...
> $ Age        : int  24 22 16 22 49 21 62 36 21 75 ...
>$ Age.Group  : Factor w/ 5 levels "> 80","16-20",..: 3 3 2 3 4 3 5 3 3
>5
>...
>$ Town       : Factor w/ 885 levels "Abbey Hey","Aberdare, Conwy",..:
>781
>259 421 259 229 92 836 276 594 276 ...
>$ Postcode   : Factor w/ 987 levels "AB10","AB16",..: 888 888 886 888
>884
>685 270 301 78 300 ...
>$ Region     : Factor w/ 11 levels "East Midlands",..: 9 9 9 9 9 9 9 9
>9 9
>...
> $ Latitude   : num  50.3 50.3 50.3 50.4 50.5 ...
> $ Longitude  : num  -3.66 -3.8 -3.61 -3.65 -3.52 ...
>$ Bread      : Factor w/ 8 levels "Bap","Barm","Batch",..: 7 7 1 7 7 7
>7 7
>7 6 ...
>$ Icon       : Factor w/ 8 levels "measle_brown",..: 2 2 1 2 2 2 2 2 2
>8
>...
>
>The following command works on another similar data frame, but not on
>this
>one.
>
>>England+stat_bin2d(aes(x=Longitude,y=Latitude,color=factor(Bread$Bread),fill=factor(Bread$Bread)),size=.5,bins=200,alpha=.5,data=Bread)
>
>It returns the following error:
>
>Error in Bread$Sex : $ operator is invalid for atomic vectors
>
>What am I doing wrong here? I'm new to R, so I'm not sure if this is
>easy
>or difficult to solve.
>
>Thanks in advance!
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>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.



More information about the R-help mailing list