As much as R is popular in data analysis, R becomes more and more favored in geospatial analysis and visualization.
To introduce spatial data, let first start with comman data. Basic R data types: vector, factor, matrix, data.frame, and list.
Data and Plots
There are many ways to munipulate and visualize data in R, including, typically, the basic and the tidyverse framework. Let’s warm up with plotting data.frame.
basic plot
attach(mtcars)
par(mfrow = c(1,2))
plot(mpg, wt, main = "wt vs.
Here is another comparison between two basic functions transform and within, and a tidyverse function dplyr::mutate. They all can be used for data munipulation, adding a new column to a data.frame.
head(mtcars)
## mpg cyl disp hp drat wt qsec vs am gear carb
## Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
## Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.
A detailed introduction on subsetting is seen in Hadley Wickham’s Advanced R.
The three subsetting operators.
The six types of subsetting.
Important differences in behaviour for different objects (e.g., vectors, lists, factors, matrices, and data frames).
Benjamin on Stack Overflow answered the question 1 of the comparison between subset() and dplyr::filter().
They are, indeed, producing the same result, and they are very similar in concept.
From the point of atmospheric science, NCL has certain natural advantages in dealing with self-described meteorological data formats, but R is improving significantly.
Unformated Binary
I have to say both NCL and R are not as good at reading/writing binary files as Fotran, though technically they are able to do the job.
Self-decribed Binary
NCL uses a single function addfile to handle all format (netCDF, HDF, GRIB, CCM, shapefile), while R requires additional packages.
I used to blog a little bit on Blogger when I was in China. I have stopped blogging for a long time since the emergency of social networks. Looking back at what I wrote when I was a young college student, I couldn’t help but feel how different I am right now. I really hope I can start likeing writting things again, focusing on R & Data Science from a geoscience perspective.