R Representation.

Uploaded on:
Category: Education / Career
R Representation. SCS Short Course Walk 14, 2008. Antiquarianism. Archeological campaign Fundamental illustrations – simple and adaptable Grid (trellis) representation – effective yet less adaptable Rgl – decent 3d yet difficult Huge amounts of new stuff: e.g. > install.packages("heplots") > library(heplots)
Slide 1

R Graphics SCS Short Course March 14, 2008

Slide 2

Archeology Archeological campaign Basic illustrations – simple and adaptable Lattice (trellis) design – capable yet less adaptable Rgl – pleasant 3d however difficult Tons of new stuff: e.g. > install.packages(“heplots”) > library(heplots) > library(help=heplots) Special reason: library(car): avp being developed: Plot3d.R

Slide 3

Goals for representation Two purposes for design: Exploratory need something brisk that can create charts as quick as your psyche can get a handle on them Presentation need adaptability to meet production prerequisites

Slide 4

Why ‘Lattice=Trellis’ illustrations Lattice (trellis) illustrations: developed at Bell Labs in mid 80s Marginality versus Conditional affiliation Motivation was issue of seeing important structures in higher dimensional information, the issue\'s stub caught by Simpson’s Paradox: two dimensional perspectives of information show negligible affiliation But contingent affiliation can be altogether diverse Interaction: restrictive affiliation can be distinctive for distinctive estimations of arbitrator variables

Slide 5

Smoking and Life Expectancy Source of demographic information (from the CIA): http://www.nationmaster.com/Two variables: -Life Expectancy -Cigarette Consumption Per Capita > dl = read.csv("http://www.math.yorku.ca/~georges/Data/CigLE.csv") > head(dl)

Slide 6

Data > head(dl) X Country Continent LE CigCon 1 Afghanistan Asia 35.5 98 2 Albania Europe 61.4 NA 3 Algeria Africa 60.6 1021 4 Andorra Europe 72.2 NA 5 Angola Africa 33.4 571 6 Antigua and Barbuda South America 61.9 NA > tail(dl) X Country Continent LE CigCon 184 Vietnam Asia 61.3 NA 185 Yemen Asia 49.3 NA 186 Zambia Africa 34.9 408 187 Ethiopia Africa NA 87 188 Venezuela South America NA 1079 189 Zimbabwe Africa NA 399

Slide 7

Regression > table( LE = !is.na( dl$LE) , CigCon = !is.na(dl$CigCon)) CigCon LE FALSE TRUE FALSE 0 3 TRUE 83 103 > fit = lm( LE ~ CigCon , dl , na.action = na.omit) > summary(fit) Call: lm(formula = LE ~ CigCon, information = dl, na.action = na.omit) Residuals: Min 1Q Median 3Q Max - 19.4576 - 5.8225 0.8188 5.3636 17.8291 Coefficients: Estimate Std. Mistake t esteem Pr(>|t|) (Intercept) 4.799e+01 1.371e+00 34.995 < 2e-16 *** CigCon 8.528e-03 9.007e-04 9.468 1.33e-15 *** - Signif. codes: 0 "***" 0.001 "**" 0.01 "*" 0.05 "." 0.1 " 1 Residual standard slip: 8.158 on 101 degrees of opportunity (86 perceptions erased because of missingness) Multiple R-Squared: 0.4702, Adjusted R-squared: 0.465 F-measurement: 89.64 on 1 and 101 DF, p-esteem: 1.333e-15

Slide 8

Interpreting coefficient Regression coefficient for CigCon is 0.008529 An increment in 1 cigarette for each year expands Life Expectancy by 0.008529 years An increment in 1 cigarette for each day builds Life Expectancy by 365 x 0.008529 = 3.11 years

Slide 9

All it takes is 3 cigarettes a day to add 10 years to your life.

Slide 10

Why illustrations! Continuously take a gander at your information The plot work: The Joys of Object-Oriented Programming: plot is a non specific capacity so it does diverse things to various types of articles What does it do to a relapse object? > plot ( fit )

Slide 11

Basic relapse diagnostics

Slide 16

So ‘plot’ a fitted relapse to get some demonstrative plots But diagnostics insufficient to rouse understanding What happens on the off chance that we plot an information outline? > plot( dl )

Slide 18

Basic representation capacities in R Axis Generic capacity to add an Axis to a Plot abline Add Straight Lines to a Plot bolts Add Arrows to a Plot assocplot Association Plots axTicks Compute Axis Tickmark Locations hub Add an Axis to a Plot axis.POSIXct Date and Date-time Plotting Functions barplot Bar Plots box Draw a Box around a Plot boxplot Box Plots bxp Draw Box Plots from Summaries cdplot Conditional Density Plots shape Display Contours coplot Conditioning Plots bend Draw Function Plots dotchart Cleveland Dot Plots filled.contour Level (Contour) Plots fourfoldplot Fourfold Plots casing Create/Start a New Plot Frame design bundle The R Graphics Package matrix Add Grid to a Plot hist Histograms hist.POSIXt Histogram of a Date or Date-Time Object

Slide 19

Basic illustrations capacities in R distinguish Identify Points in a Scatter Plot picture Display a Color Image format Specifying Complex Plot Arrangements legend Add Legends to Plots lines Add Connected Line Segments to a Plot locator Graphical Input matplot Plot Columns of Matrices mosaicplot Mosaic Plots mtext Write Text into the Margins of a Plot sets Scatterplot Matrices panel.smooth Simple Panel Plot standard Set or Query Graphical Parameters persp Perspective Plots Pie Charts

Slide 20

Basic design capacities in R Generic capacity plot and its techniques: plot Generic X-Y Plotting plot.data.frame Plot Method for Data Frames plot.default The Default Scatterplot Function plot.design Plot Univariate Effects of a \'Design\' or Model plot.factor Plotting Factor Variables plot.formula Formula Notation for Scatterplots plot.histogram Plot Histograms plot.table Plot Methods for "table" Objects plot.window Set up World Coordinates for Graphics Window plot.xy Basic Internal Plot Function

Slide 21

Basic illustrations capacities in R focuses Add Points to a Plot Polygon Drawing rect Draw One or More Rectangles mat Add a Rug to a Plot screen Creating and Controlling Multiple Screens on a Single Device portions Add Line Segments to a Plot spineplot Spine Plots and Spinograms stars Star (Spider/Radar) Plots and Segment Diagrams Stem-and-Leaf Plots stripchart 1-D Scatter Plots strwidth Plotting Dimensions of Character Strings and Math Expressions sunflowerplot Produce a Sunflower Scatter Plot images Draw Symbols (Circles, Squares, Stars, Thermometers, Boxplots) on a Plot content Add Text to a Plot title Plot Annotation xinch Graphical Units

Slide 22

Continue with case script record: From R: > download.file( http://www.math.yorku.ca/~georges/R/R-Graphics.R , “R-Graphics.R”) Then load in R by means of “File | Open script …”

Slide 23

Links Local wiki: (contact georges@yorku.ca for record to alter) http://wiki.math.yorku.ca navigate to R Index R Graphics: http://csg.sph.umich.edu/docs/R/design 1.pdf Gallery of R Graphics: http://addictedtor.free.fr/graphiques/extremely favor, it is pleasant to have a customary rendition R Graphics Gallery: http://research.stowers-in

View more...