Hi there,
Using ggplot, I have successfully created a plot that contains 37 separate line plots that each represent a trend in precipitation over 140 years. However, what I would like to do is show the curve that is the "median" of these lines. Is this possible to do??
Here is what I have so far in an attempt to do this, but I am not certain if it is the correct approach to create the desired median line - the first variable shows x-variable objects (each 1-dimensional) and the second variable shows the y-variable objects (3-dimensional):
RCP1pctCO2Median <- median(cbind(get, IPSL, IPSLMR, IPSL5, MIROC, HadGEM, MPI, MPI5, GFDL, GFDL5))?
RCP1pctCO2ModelMedian <- median(cbind(Model2, Model10, Model18, Model26, subset14, Model42, subset20, subset24, Model60, Model68))
The first variable appears to work, but it only returns one value, and I want all of the 140 values corresponding to whichever curve was returned. Why is it that only one value returns? Here is what the variable contains:
RCP1pctCO2Median[1] 1.189044
When I run the second variable the same way, I receive the following error:
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
'x' must be atomic
Why does this appear?? I tried "unlist" and "as.vector", but the same error appears.
If it helps, to show what the 1-dimensional objects of the first variable look like, here is an example of one (the object "get"):
Model2 <- brick("MaxPrecCCCMACanESM21pctCO2.nc", var = "onedaymax")
Model2class : RasterBrick
dimensions : 64, 128, 8192, 140 (nrow, ncol, ncell, nlayers)
resolution : 2.8125, 2.789327 (x, y)
extent : -181.4062, 178.5938, -89.25846, 89.25846 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : C:/Users/Travis/Documents/Other documents/All netCDF files/netcdffiles/MaxPrecCCCMACanESM21pctCO2.nc
names : X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, ...
z-value : 1, 140 (min, max)
varname : onedaymax
In any case, I am not even certain if what I have done above is the correct approach altogether to create a median line, but I would greatly appreciate any assistance! Your feedback would be extremely valuable to me!
Thank you, and I very much look forward to hearing from you!