[R] map at fips level using multiple variables
bby2103 at columbia.edu
bby2103 at columbia.edu
Thu Dec 8 05:14:27 CET 2011
Hi David,
Sorry it sounds vague.
Here is my current code, which gives the distribution of family size
at US county level. You will see on a US map family size distribution
represented by different colors.
Now if i have another variable income, which has 3 categories(<50k,
50k-80k,>80k). How do I show 5x3 categories on the map? I guess I
could always create a third variable to do this. Just wondering maybe
there is a function to do this readily?
Thank you!
Bonnie Yuan
y=data1$size
x11()
hist(y,nclass=15) # histogram of y
fivenum(y)
# specify the cut-off point of y
y.colorBuckets=as.numeric(cut(y, c(1,2, 3,6)))
# legend showing the cut-off points.
legend.txt=c("0-1","1-2","2-3","3-6",">6")
colorsmatched=y.colorBuckets[match(county.fips$fips,fips[,1])]
x11()
map("county", col = colors[colorsmatched], fill = TRUE, resolution = 0)
map("state", col = "white", fill = FALSE, add = TRUE, lty = 1, lwd = 0.2)
title("Family Size")
legend("bottom", legend.txt, horiz = TRUE, fill = colors, cex=0.7)
Quoting David Winsemius <dwinsemius at comcast.net>:
>
> On Dec 7, 2011, at 6:12 PM, bby2103 at columbia.edu wrote:
>
>> Hi, I just started playing with county FIPS feature in maps package
>> which allows geospatial visualization of variables on US county
>> level. Pretty cool.
>
> Got code?
>
>>
>> I did some search but couldn't find answer to this question--how
>> can I map more than 2 variables on US map?
>
> "2 variables" is a bit on the vague side for programming purposes.
>
>> For example, you can map by the breakdown of income or family size.
>> How do you further breakdown based on the values of both variables
>> and show them on the county FIPS level?
>
> "breakdown" suggests a factor construct. If so, then :
>
> ?interaction
>
> But the "show" part of the question remains very vague.
>
> Can't you be a bit more specific? What DO you want?
>
> --
> David Winsemius, MD
> West Hartford, CT
More information about the R-help
mailing list