<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>figures | Geochemistry of shells and oceans</title><link>https://www.benlinzmeier.rocks/tag/figures/</link><atom:link href="https://www.benlinzmeier.rocks/tag/figures/index.xml" rel="self" type="application/rss+xml"/><description>figures</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><copyright>© 2021 Benjamin J. Linzmeier</copyright><lastBuildDate>Mon, 15 Nov 2021 21:24:56 +0000</lastBuildDate><image><url>https://www.benlinzmeier.rocks/media/icon_hu8ded995c33c39b4390835f2ba388373c_36984_512x512_fill_lanczos_center_2.png</url><title>figures</title><link>https://www.benlinzmeier.rocks/tag/figures/</link></image><item><title>Making a geological map with Macrostrat and ggplot</title><link>https://www.benlinzmeier.rocks/post/making-a-geological-map-with-macrostrat-and-ggplot/</link><pubDate>Mon, 15 Nov 2021 21:24:56 +0000</pubDate><guid>https://www.benlinzmeier.rocks/post/making-a-geological-map-with-macrostrat-and-ggplot/</guid><description>
&lt;script src="https://www.benlinzmeier.rocks/post/making-a-geological-map-with-macrostrat-and-ggplot/index_files/header-attrs/header-attrs.js">&lt;/script>
&lt;p>Geological maps are important to include as figures in many papers. Often creating them can rely on existing figures or shapefiles that are in GIS. The &lt;a href="https://macrostrat.org/">Macrostrat database&lt;/a> contains shapefiles for many Formations that can be returned using the &lt;a href="https://macrostrat.org/api/v2/geologic_units/map">API&lt;/a>.&lt;/p>
&lt;p>First we load the important packages. We will use data from &lt;a href="https://www.naturalearthdata.com/">Natural Earth&lt;/a> to create the basemap. We also use a few other tools to get data from &lt;a href="https://macrostrat.org/">Macrostrat database&lt;/a> and convert it to a simple feature (sf) object.&lt;/p>
&lt;pre class="r">&lt;code>library(ggplot2)
library(sf)&lt;/code>&lt;/pre>
&lt;pre>&lt;code>## Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1&lt;/code>&lt;/pre>
&lt;pre class="r">&lt;code>library(ggspatial)
library(rnaturalearth)
library(rnaturalearthdata)
library(geojsonsf)
library(RCurl)&lt;/code>&lt;/pre>
&lt;p>We load the state outlines for the map using this code.&lt;/p>
&lt;pre class="r">&lt;code>South_base &amp;lt;- ne_states(country = &amp;quot;united states of america&amp;quot;, returnclass = &amp;quot;sf&amp;quot;)&lt;/code>&lt;/pre>
&lt;p>Here we get data from Macrostrat. To change this to your formation of interest, use &lt;a href="https://macrostrat.org/sift/#/">the sift interface&lt;/a> to search for a unique &lt;code>strat_name_id&lt;/code> for a formation of interest.&lt;/p>
&lt;p>The data are then converted to a &lt;code>wkt&lt;/code> and finally an &lt;code>sf&lt;/code> object.&lt;/p>
&lt;pre class="r">&lt;code>y &amp;lt;- getURL(&amp;quot;https://macrostrat.org/api/v2/geologic_units/map?strat_name_id=2683&amp;amp;format=geojson_bare&amp;quot;,
.opts = curlOptions(ssl.verifypeer=FALSE, verbose=TRUE))
sf_temp &amp;lt;- geojson_wkt(y)
sf_map &amp;lt;- st_as_sf(sf_temp, wkt = &amp;#39;geometry&amp;#39;, crs = 4326) &lt;/code>&lt;/pre>
&lt;p>We then use ggplot to build the map.&lt;/p>
&lt;p>First, we can create just the simple background base map.&lt;/p>
&lt;pre class="r">&lt;code>ggplot(data = South_base) +
geom_sf()&lt;/code>&lt;/pre>
&lt;p>&lt;img src="https://www.benlinzmeier.rocks/post/making-a-geological-map-with-macrostrat-and-ggplot/index_files/figure-html/unnamed-chunk-2-1.png" width="672" />
Then we can add the geological data.&lt;/p>
&lt;pre class="r">&lt;code>ggplot(data = South_base) +
geom_sf()+
geom_sf(data = sf_map,
color = &amp;quot;#A6D84A&amp;quot;,
fill = &amp;quot;#A6D84A&amp;quot;,
alpha = .5)&lt;/code>&lt;/pre>
&lt;p>&lt;img src="https://www.benlinzmeier.rocks/post/making-a-geological-map-with-macrostrat-and-ggplot/index_files/figure-html/unnamed-chunk-3-1.png" width="672" />
Next we can select a smaller area and then add a North arrow.&lt;/p>
&lt;pre class="r">&lt;code>ggplot(data = South_base) +
geom_sf()+
geom_sf(data = sf_map,
color = &amp;quot;#A6D84A&amp;quot;,
fill = &amp;quot;#A6D84A&amp;quot;,
alpha = .5)+
coord_sf(xlim = c(-90, -82), ylim = c(28, 37.5), expand = FALSE)+
annotation_north_arrow(location = &amp;quot;bl&amp;quot;, which_north = &amp;quot;true&amp;quot;,
pad_x = unit(0.75, &amp;quot;in&amp;quot;), pad_y = unit(0.5, &amp;quot;in&amp;quot;),
style = north_arrow_fancy_orienteering)&lt;/code>&lt;/pre>
&lt;p>&lt;img src="https://www.benlinzmeier.rocks/post/making-a-geological-map-with-macrostrat-and-ggplot/index_files/figure-html/unnamed-chunk-4-1.png" width="672" />&lt;/p>
&lt;p>Finally, we add a scale bar, background colors, dashes, and fill the ocean with a light blue.&lt;/p>
&lt;pre class="r">&lt;code>ggplot(data = South_base) +
geom_sf()+
geom_sf(data = sf_map,
color = &amp;quot;#A6D84A&amp;quot;,
fill = &amp;quot;#A6D84A&amp;quot;,
alpha = .5)+
coord_sf(xlim = c(-90, -82), ylim = c(28, 37.5), expand = FALSE)+
annotation_north_arrow(location = &amp;quot;bl&amp;quot;, which_north = &amp;quot;true&amp;quot;,
pad_x = unit(0.75, &amp;quot;in&amp;quot;), pad_y = unit(0.5, &amp;quot;in&amp;quot;),
style = north_arrow_fancy_orienteering)+
annotation_scale(location = &amp;quot;bl&amp;quot;, width_hint = 0.5) +
theme(panel.grid.major = element_line(color = gray(.5),
linetype = &amp;quot;dashed&amp;quot;,
size = 0.5),
panel.background = element_rect(fill = &amp;quot;aliceblue&amp;quot;))+
theme_bw()&lt;/code>&lt;/pre>
&lt;pre>&lt;code>## Scale on map varies by more than 10%, scale bar may be inaccurate&lt;/code>&lt;/pre>
&lt;p>&lt;img src="https://www.benlinzmeier.rocks/post/making-a-geological-map-with-macrostrat-and-ggplot/index_files/figure-html/Final%20Map-1.png" width="672" />&lt;/p>
&lt;p>And there you have a map of a geological unit overlain on a state map in R.&lt;/p></description></item><item><title>Basic figure creation in R with ggplot</title><link>https://www.benlinzmeier.rocks/post/basic-figure-creation-in-r-with-ggplot/</link><pubDate>Tue, 12 Oct 2021 23:15:18 +0000</pubDate><guid>https://www.benlinzmeier.rocks/post/basic-figure-creation-in-r-with-ggplot/</guid><description>
&lt;script src="https://www.benlinzmeier.rocks/post/basic-figure-creation-in-r-with-ggplot/index_files/header-attrs/header-attrs.js">&lt;/script>
&lt;div id="scientific-programming" class="section level2">
&lt;h2>Scientific programming&lt;/h2>
&lt;p>R is an open source programming language with a strong use in data analysis. Generally it is used more often for open statistical tools. It is used by some in the Geoscience community.&lt;/p>
&lt;p>Python is another widely used programming language in Geosciences. It has similar capabilities to R but different strengths.&lt;/p>
&lt;p>Much of the most useful scientific programming you are likely to do focuses on data reduction and processing to test specific hypotheses. Creating figures using code in either R or Python allows you to design your data display while collecting data. You can also be sure to link the data to the figure easily and in a reproducible way.&lt;/p>
&lt;/div>
&lt;div id="lab-tasks" class="section level2">
&lt;h2>Lab tasks&lt;/h2>
&lt;p>In this lab, you will be making figures using randomly generated data and publicly available geology data. I have code chunks embedded below that you can copy/paste into your own instance of R Studio and then execute.&lt;/p>
&lt;/div>
&lt;div id="loading-packages" class="section level2">
&lt;h2>Loading packages&lt;/h2>
&lt;p>R is powerful because people make and share &lt;em>packages&lt;/em> of code that can streamline doing scientific tasks. &lt;em>Packages&lt;/em> contain smaller &lt;em>functions&lt;/em> that are self-contained and accomplish a set of specific tasks. For example, a very simple function is defined below.&lt;/p>
&lt;pre class="r">&lt;code>AddTwo &amp;lt;- function(x){
y &amp;lt;- x + 2
return(y)
}
AddTwo(3)&lt;/code>&lt;/pre>
&lt;pre>&lt;code>## [1] 5&lt;/code>&lt;/pre>
&lt;p>This function takes a number given to it, X, and returns that number plus two. Other functions have more in depth operations, but ideally code is written to execute the smallest steps possible for each action to improve human readability and ease troubleshooting.&lt;/p>
&lt;p>We will use the packages below. They need to be opened after installing. Official packages for R are shared on CRAN. The functions below install and load the packages. The package &lt;code>ggplot2&lt;/code> uses the ‘grammar of graphics’ to make complex plots efficient to code. The package &lt;code>tidyverse&lt;/code> includes utilities for data summarization and transformation. For additional documentation about different commonly used R functions &lt;a href="https://www.rstudio.com/resources/cheatsheets/">look at these cheetsheets&lt;/a>.&lt;/p>
&lt;pre class="r">&lt;code># install.packages(&amp;quot;ggplot2&amp;quot;)
# install.packages(&amp;quot;tidyverse&amp;quot;)
library(ggplot2)
library(tidyverse)&lt;/code>&lt;/pre>
&lt;/div>
&lt;div id="making-figures" class="section level2">
&lt;h2>Making figures&lt;/h2>
&lt;p>The simplest figure we can make is a crossplot with X and Y data. Below is an example using randomly generated X and Y points. This plot and dataset use only the basic functions included with R (commonly known as Base R).&lt;/p>
&lt;div id="base-r" class="section level3">
&lt;h3>Base R&lt;/h3>
&lt;pre class="r">&lt;code>N &amp;lt;- 100
X &amp;lt;- rnorm(n = N, mean = 5, sd = 2)
Y &amp;lt;- rnorm(n = N, mean = 8, sd = 3)
plot(x = X, y = Y)&lt;/code>&lt;/pre>
&lt;p>&lt;img src="https://www.benlinzmeier.rocks/post/basic-figure-creation-in-r-with-ggplot/index_files/figure-html/random_data-1.png" width="672" />&lt;/p>
&lt;/div>
&lt;div id="simple-crossplot-with-ggplot" class="section level3">
&lt;h3>Simple crossplot with ggplot&lt;/h3>
&lt;p>To do this same thing with &lt;code>ggplot2&lt;/code> we use a slightly different syntax for the figure. First we must make a data frame with our data (think excel table).&lt;/p>
&lt;pre class="r">&lt;code>RandomData &amp;lt;- as.data.frame(cbind(X,Y))
ggplot(data = RandomData, aes(x = X, y = Y))+
geom_point()+
theme_bw()&lt;/code>&lt;/pre>
&lt;p>&lt;img src="https://www.benlinzmeier.rocks/post/basic-figure-creation-in-r-with-ggplot/index_files/figure-html/random_ggplot-1.png" width="384" />&lt;/p>
&lt;/div>
&lt;div id="more-complex-with-ggplot" class="section level3">
&lt;h3>More complex with ggplot&lt;/h3>
&lt;p>Let’s get more complicated, because we often want to use data containing multiple axes (e.g. location, time). Using software other than Excel makes these sorts of figures much easier to create. My preferred method is using the &lt;code>ggplot&lt;/code> and associated packages for R. With &lt;code>ggplot&lt;/code>, the &lt;a href="https://www.tandfonline.com/doi/abs/10.1198/jcgs.2009.07098">grammar of graphics&lt;/a> guides the creation of a plot and allows users to trace the source of data and make adjustments quickly. There are also preset &lt;a href="https://ggplot2.tidyverse.org/reference/ggtheme.html">themes for ggplot&lt;/a> that quickly adjust the overall style of figures for a more professional and consistent look.&lt;/p>
&lt;p>In the code below we use the dataframe &lt;code>RandomData&lt;/code> to feed into creating the plot. We set plot aesthetics using &lt;code>aes&lt;/code> and name individual parameters we want to include in the plot. Here we use &lt;code>x&lt;/code>, &lt;code>y&lt;/code>, &lt;code>color&lt;/code>, and &lt;code>shape&lt;/code> because we are interested in seeing all of these permutations in our crossplot. We then indicate what type of plot we want to make using &lt;code>geom_point&lt;/code> to indicate a scatterplot. The code could stop here, but I also adjust the size of the points with &lt;code>size = 2&lt;/code> and adjust the theme of the plot using &lt;code>theme_bw()&lt;/code>. Note that each adjustment is included through the use of a &lt;code>+&lt;/code> after the previous component of the plot.&lt;/p>
&lt;pre class="r">&lt;code>Time &amp;lt;- 1:N
Site &amp;lt;- sample( LETTERS[1:4], 50, replace=TRUE, prob=c(0.2, 0.2, 0.4, 0.02) )
RandomData &amp;lt;- data.frame(X,Y, Time, Site)
ggplot(data = RandomData, aes(x = X, y = Y, color = Time, shape = Site))+
geom_point(size = 2)+
theme_bw()&lt;/code>&lt;/pre>
&lt;p>&lt;img src="https://www.benlinzmeier.rocks/post/basic-figure-creation-in-r-with-ggplot/index_files/figure-html/randomExtra_ggplot-1.png" width="672" />&lt;/p>
&lt;/div>
&lt;div id="time-series-ggplot" class="section level3">
&lt;h3>Time series ggplot&lt;/h3>
&lt;p>It is also easier to create time series plots with this. Below, I add lines that connect the points from each site. Note that I use both &lt;code>geom_point&lt;/code> and &lt;code>geom_line&lt;/code> to create layered lines and points. If you use one or the other you will only get one or the other.&lt;/p>
&lt;pre class="r">&lt;code>ggplot(RandomData, aes(x = Time, y = Y, color = Site))+
geom_point(size = 2)+
geom_line()+
theme_bw()&lt;/code>&lt;/pre>
&lt;p>&lt;img src="https://www.benlinzmeier.rocks/post/basic-figure-creation-in-r-with-ggplot/index_files/figure-html/timeSeries-1.png" width="672" />&lt;/p>
&lt;/div>
&lt;/div>
&lt;div id="grain-size-analysis" class="section level2">
&lt;h2>Grain size analysis&lt;/h2>
&lt;p>We have estimated and qualitatively described grain sizes so far in class. Quantitative measurements can be important for monitoring processes in environments and subdividing paleoenvironments. We will likely talk about this more, but I wanted to add a crash course in it with our lab creating figures.&lt;/p>
&lt;p>As with any population of measurements, there are multiple parameters than can be extracted from the measurement of a single variable within a sample. Below are aspects of distributions that are used to describe sediment size distributions.&lt;/p>
&lt;div id="descriptive-statistics" class="section level3">
&lt;h3>Descriptive statistics&lt;/h3>
&lt;div id="mean" class="section level4">
&lt;h4>Mean&lt;/h4>
&lt;p>Sum of all values divided by the number of values.
&lt;!-- $$\bar{X} = \frac{\sum_{i=1}^{n} x_{i}}{n}$$ -->&lt;/p>
&lt;/div>
&lt;div id="standard-deviation" class="section level4">
&lt;h4>Standard deviation&lt;/h4>
&lt;p>Description of how narrowly distributed the data are. Calculated based on distance of individual analyses from the mean.
&lt;!-- $$s = \sqrt{s^{2}} = \sqrt{\frac{SS}{N - 1}} = \sqrt{\frac{\sum (x_{i} - \bar{x})^{2}}{N - 1}}$$ -->&lt;/p>
&lt;/div>
&lt;div id="skew" class="section level4">
&lt;h4>Skew&lt;/h4>
&lt;p>Can be interpreted based on the difference between the mean and the median of the distribution. The mean is displaced towards the longer tail of the distribution.&lt;/p>
&lt;/div>
&lt;div id="kurtosis" class="section level4">
&lt;h4>Kurtosis&lt;/h4>
&lt;p>Increasing kurtosis is flattening the distribution. Higher kurtosis is more width and less hight near the mean.&lt;/p>
&lt;p>Below is an example of a probability distribution based on the random data. Blue vertical lines are equal to two times the standard deviation and encompass 95% of the dataset. The black vertical line is the median value and the red vertical line is the mean.&lt;/p>
&lt;pre class="r">&lt;code>ggplot(RandomData, aes(x = X))+
geom_density()+
geom_vline(aes(xintercept = mean(X)), color = &amp;quot;red&amp;quot;)+
geom_vline(aes(xintercept = median(X)), color = &amp;quot;black&amp;quot;)+
geom_vline(aes(xintercept = mean(X)+2*sd(X)), color = &amp;quot;blue&amp;quot;)+
geom_vline(aes(xintercept = mean(X)-2*sd(X)), color = &amp;quot;blue&amp;quot;)+
theme_bw()&lt;/code>&lt;/pre>
&lt;p>&lt;img src="https://www.benlinzmeier.rocks/post/basic-figure-creation-in-r-with-ggplot/index_files/figure-html/probability%20density-1.png" width="672" />&lt;/p>
&lt;/div>
&lt;/div>
&lt;/div>
&lt;div id="real-datasets" class="section level2">
&lt;h2>Real datasets&lt;/h2>
&lt;p>Let’s load some sediment size datasets now.&lt;/p>
&lt;pre class="r">&lt;code>GrainSize&amp;lt;-read_delim(&amp;quot;https://www.ngdc.noaa.gov/mgg/geology/data/g00127/g00127interval.txt&amp;quot;, delim = &amp;quot;\t&amp;quot;)
GrainSize$device &amp;lt;- as.factor(GrainSize$device)
GrainSize &amp;lt;- GrainSize[grepl(&amp;quot;grab&amp;quot;, GrainSize$device),]&lt;/code>&lt;/pre>
&lt;p>The first function above downloads, parses, and incorporates data into R all within the function. You can view other important pieces of the dataset with the following. One column, the &lt;code>device&lt;/code> column is changed to a factor and then we select only those grain size analyses that are from grab samples using a &lt;code>regex&lt;/code> match.&lt;/p>
&lt;p>&lt;strong>If you need to figure out what a function does, you can enter the name of the function with a question mark in front of it into your console and documentation will be opened. For example &lt;code>?read_delim()&lt;/code> opens the documentation for the function &lt;code>read_delim&lt;/code>. If you do not know what needs to be entered use &lt;code>??&lt;/code> in front of a simple search to look through all documentation for a useful function.&lt;/strong>&lt;/p>
&lt;p>The function below, &lt;code>colnames&lt;/code>, returns a vector of the column names.&lt;/p>
&lt;pre class="r">&lt;code>colnames(GrainSize)&lt;/code>&lt;/pre>
&lt;pre>&lt;code>## [1] &amp;quot;mggid&amp;quot; &amp;quot;ship&amp;quot; &amp;quot;cruise&amp;quot;
## [4] &amp;quot;sample&amp;quot; &amp;quot;device_code&amp;quot; &amp;quot;device&amp;quot;
## [7] &amp;quot;subcore&amp;quot; &amp;quot;interval&amp;quot; &amp;quot;replicate&amp;quot;
## [10] &amp;quot;analysis_type&amp;quot; &amp;quot;depth_top_cm&amp;quot; &amp;quot;depth_top_mm&amp;quot;
## [13] &amp;quot;depth_bot_cm&amp;quot; &amp;quot;depth_bot_mm&amp;quot; &amp;quot;test_date&amp;quot;
## [16] &amp;quot;test_time&amp;quot; &amp;quot;total_weight&amp;quot; &amp;quot;coarse_meth&amp;quot;
## [19] &amp;quot;fine_meth&amp;quot; &amp;quot;coarse_fine_boundary&amp;quot; &amp;quot;coarse_boundary&amp;quot;
## [22] &amp;quot;fine_boundary&amp;quot; &amp;quot;pct_coarser&amp;quot; &amp;quot;pct_finer&amp;quot;
## [25] &amp;quot;pct_gravel&amp;quot; &amp;quot;pct_sand&amp;quot; &amp;quot;pct_silt&amp;quot;
## [28] &amp;quot;pct_clay&amp;quot; &amp;quot;pct_mud&amp;quot; &amp;quot;usc_gravel&amp;quot;
## [31] &amp;quot;usc_sand&amp;quot; &amp;quot;usc_fines&amp;quot; &amp;quot;meth_description&amp;quot;
## [34] &amp;quot;mean_mm&amp;quot; &amp;quot;mean_phi&amp;quot; &amp;quot;median_phi&amp;quot;
## [37] &amp;quot;modal_phi&amp;quot; &amp;quot;skewness&amp;quot; &amp;quot;kurtosis&amp;quot;
## [40] &amp;quot;std_dev&amp;quot; &amp;quot;sort_coeff&amp;quot; &amp;quot;interval_comments&amp;quot;&lt;/code>&lt;/pre>
&lt;pre class="r">&lt;code>ggplot(GrainSize, aes(x=median_phi, y=mean_phi, color = skewness))+
geom_point()+
theme_bw()&lt;/code>&lt;/pre>
&lt;pre>&lt;code>## Warning: Removed 5347 rows containing missing values (geom_point).&lt;/code>&lt;/pre>
&lt;p>&lt;img src="https://www.benlinzmeier.rocks/post/basic-figure-creation-in-r-with-ggplot/index_files/figure-html/preliminary_plot-1.png" width="672" />&lt;/p>
&lt;/div>
&lt;div id="combining-datasets" class="section level2">
&lt;h2>Combining datasets&lt;/h2>
&lt;p>In the following code chunk, we download the location data, then create smaller dataframes of grain size and location to combine.&lt;/p>
&lt;p>We use the logical test of &lt;code>is.na&lt;/code> to determine if an individual entry is blank. To only select non-blank entries, we use the &lt;code>!&lt;/code> operator, that makes the logical test &lt;em>is not NA&lt;/em>.&lt;/p>
&lt;p>The &lt;code>merge&lt;/code> function combines both datasets using a few columns so we have unique locations. This allows us to start plotting grain size information, &lt;code>mean_phi&lt;/code> for instance, against other parameters like &lt;code>water_depth&lt;/code>.&lt;/p>
&lt;p>I then plot up the data with a point cloud showing the relationship between the standard deviation of the data and the mean grain size.&lt;/p>
&lt;pre class="r">&lt;code>Location&amp;lt;-read_delim(&amp;quot;https://www.ngdc.noaa.gov/mgg/geology/data/g00127/g00127sample.txt&amp;quot;, delim = &amp;quot;\t&amp;quot;)&lt;/code>&lt;/pre>
&lt;pre>&lt;code>##
## -- Column specification --------------------------------------------------------
## cols(
## .default = col_character(),
## device_code = col_double(),
## year = col_double(),
## lat = col_double(),
## lon = col_double(),
## water_depth = col_double(),
## core_length = col_double(),
## comments = col_logical()
## )
## i Use `spec()` for the full column specifications.&lt;/code>&lt;/pre>
&lt;pre>&lt;code>## Warning: 17970 parsing failures.
## row col expected actual file
## 1 -- 25 columns 26 columns &amp;#39;https://www.ngdc.noaa.gov/mgg/geology/data/g00127/g00127sample.txt&amp;#39;
## 2 -- 25 columns 26 columns &amp;#39;https://www.ngdc.noaa.gov/mgg/geology/data/g00127/g00127sample.txt&amp;#39;
## 3 -- 25 columns 26 columns &amp;#39;https://www.ngdc.noaa.gov/mgg/geology/data/g00127/g00127sample.txt&amp;#39;
## 4 -- 25 columns 26 columns &amp;#39;https://www.ngdc.noaa.gov/mgg/geology/data/g00127/g00127sample.txt&amp;#39;
## 5 -- 25 columns 26 columns &amp;#39;https://www.ngdc.noaa.gov/mgg/geology/data/g00127/g00127sample.txt&amp;#39;
## ... ... .......... .......... ....................................................................
## See problems(...) for more details.&lt;/code>&lt;/pre>
&lt;pre class="r">&lt;code>GrainLocation &amp;lt;- merge(GrainSize, Location, by = c(&amp;quot;mggid&amp;quot;, &amp;quot;ship&amp;quot;, &amp;quot;cruise&amp;quot;, &amp;quot;sample&amp;quot;))
ggplot(GrainLocation[GrainLocation$water_depth&amp;lt;500,], aes(x = mean_phi, y = std_dev, color = water_depth))+
geom_point()+
theme_bw()&lt;/code>&lt;/pre>
&lt;pre>&lt;code>## Warning: Removed 4346 rows containing missing values (geom_point).&lt;/code>&lt;/pre>
&lt;p>&lt;img src="https://www.benlinzmeier.rocks/post/basic-figure-creation-in-r-with-ggplot/index_files/figure-html/location_dataset-1.png" width="672" />&lt;/p>
&lt;/div></description></item></channel></rss>