Graphics Reference
In-Depth Information
The hclust() function provides several methods for performing the cluster analysis. The default
is "complete" ; the other possible methods are "ward" , "single" , "average" , "mcquitty" ,
"median" , and "centroid" .
See Also
See ?hclust for more information about the different clustering methods.
Creating a Vector Field
Problem
You want to make a vector field.
Solution
Use geom_segment() . For this example, we'll use the isabel data set:
library(gcookbook) # For the data set
isabel
x y z vx vy vz t speed
-83.00000 41.70000 0.035
NA
NA
NA
NA
NA
-83.00000 41.62786 0.035
NA
NA
NA
NA
NA
-83.00000 41.55571 0.035
NA
NA
NA
NA
NA
...
-62.04208 23.88036 18.035 -12.54371 -5.300128 -0.045253485 -66.96269 13.61749
-62.04208 23.80822 18.035 -12.56157 -5.254994 -0.020277001 -66.98840 13.61646
-62.04208 23.73607 18.035 -12.78071 -5.259613 0.005555035 -67.00575 13.82064
x and y are the longitude and latitude, respectively, and z is the height in kilometers. The vx , vy ,
and vz values are the wind speed components in each of these directions, in meters per second,
and speed is the wind speed.
The height ( z ) ranges from 0.035 km to 18.035 km. For this example, we'll just use the lowest
slice of data.
To draw the vectors ( Figure 13-21 ), we'll use geom_segment() . Each segment has a starting
point and an ending point. We'll use the x and y values as the starting points for each segment,
then add a fraction of the vx and vy values to get the end points for each segment. If we didn't
scale down these values, the lines would be much too long:
islice <- subset(isabel, z == min(z))
Search WWH ::




Custom Search