Map with GEOID in R - r

I have a small file with GEOIDs. (Not lat/long.) I produced this file myself. I have a hard time figuring out how I can plot this. My file has GEOIDs and a column I want to plot in R (called "y" in example below). The data looks something like this;
GEOID
y
36061015700
0.598
36061014900
0.522
36061013900
0.370
36061013300
0.407
Etc. I estimated this model in Manhattan only. (y represents Census tract cummulative log real estate returns between 2006 -- 2019 in case you are interested.) I want to plot the returns, where a darker colour would represent a higher value and vice verse.
Looking around the web, almost all explanations are with existing data, not with your own data. The current format is a data.frame, which I understand is already an issue. Is there no simple package that can plot this? Bonus points if it doesn't involve tidyverse.
Kind regards,
Alex

Related

What are the names of the graphs used in the NAPLAN? Anyone know how to plot them?

In Australia we have a test for students called NAPLAN.
The results are provided in a sort of band graph mixed with a box and whisker.
Does anyone know what they are called?
They are good because they show total range, Where the student falls in the band. What the national average is and what the students class average is.
essentially 4 data points on 1 graph.

How do I produce a probability histogram?

I've just started learning R, and was wondering, say I have the dataset quake, and I want to generate the probability histogram of quakes near Fiji, would the code simply be hist(quakes$lat,freq=F)?
A histogram shows the frequency or proportion of a given value out of all the values in a data set. You need a numeric vector as the x argument for hist(). There is no flat variable in quakes, but there is a lat variable. hist(quakes$lat, freq = F) would show the following:
This shows the north/south geographical distribution of earthquakes, centering around -20, and, since it is approximately normal (with a left skew) suggests that there is a mechanism for earthquake generation that centers around a specific latitude.
The best way to learn is to try. If you wonder if that would be the way to do it, try it.
You might also want to look at this tutorial on creating kernel density plots with ggplot.

How to plot a Flow Map in R using GPS Trajectory Data?

I have the following GPS Trajectory Data (fraction of the whole dataset):
# safegraph_id latitude longitude horizontal_accuracy id_type utc_timestamp geo_hash
# ef3a28742059bdcd65aad91ab77ffc180956b13336e93c2b75a1c6dbc56db0e1 18.458185 -66.731697 8 idfa 1506268248 de2912pqw
# 72860c415b90a7788dcfd0de748181b37f6878ba09c50ab36ddf142c82febf3d 18.412485 -66.119324 120.5433266 idfa 1505389477 de2bxrvkk
# 431e6e49111f1f7a49b9cda05f1b016f6e006b2b4c4f5b1d45a33cd65a0a4abe 18.314985 -66.091981 6 idfa 1504664544 de300n1k9
# 431e6e49111f1f7a49b9cda05f1b016f6e006b2b4c4f5b1d45a33cd65a0a4abe 18.414039 -66.103403 6 idfa 1505101204 de2bzb0vx
I'm new with R and I would like to plot a flow map so I can see the movement of the population. I have looked through some examples but is a little difficult to understand since the data used is different. Can somebody help me with this? I need to know what do I need from dataset to make the plot. Thank you.

I want to plot a point pattern that is marked by a function (in R)

I have a time series dataset with spatial data (x,y coordinates). Each point is static in location, but its value varies over time, ie. each point has its own unique function. I want to assign these functions as a mark, so I can plot the point pattern with each individual time series as a plotting symbol.
This is an exploratory step to eventually perform some spatial functional data analysis.
As an example, I want something like Figure 2 published in this article:
*Delicado,P., R. Giraldo, C. Comas, and J. Mateu. 2010. Spatial Functional Data: Some Recent Contibutions. Environmetrics 21:224-239
I'm having trouble posting an image of the figure
1) Working in R with ggplot2, I can plot a line of change in quant of each id over time:
(Fake example dataset, where x and y are Carteian coordinates, id is an individual observation, and quant are values of id at each year):
x<-c(1,1,1,2,2,2,3,3,3)
y<-c(1,1,1,2,2,2,3,3,3)
year<-c(1,2,3,1,2,3,1,2,3)
id<-c("a","a","a","b","b","b","c","c","c")
quant<-c(5,2,4,2,4,2,4,4,6)
allData<-data.frame(x,y,year,id,quant)
ggplot(allData,aes(x=year,y=quant, group=id))+geom_line()
2) Or I can plot the geographic point pattern of id:
ggplot(allData,aes(x=x,y=y,color=id))+geom_point()
I want to plot the graph from (2), but use the line plots from (1) as the point symbols (marks). Any suggestions?

3d surface plot in R, with z dimension changing over time

I have a dataset with a x-y-z structure.
X = age of arrival in the city
Y = year of arrival
Z = number of current survivors from X/Y combination
I have no problem plotting this for any given time using RGL in R. However I would like to introduce a time dimension.
I could of course make 23 plots and paste them together, but I would like to be able to manipulate the viewing on the fly, and treat the whole time series as one plot. I have Z values for 23 years. I also would like to colour my plot with an extra z2 variable, being z_year/z_(year-1). Is this possible within the RGl pakcage with some programming or is there a better package available?
Try creating a video like described on SO..
Alternative is a for-loop with a plot and delaying it -> look at ?Sys.sleep

Resources