Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

I need the following examples solved in library(grid) instead of lattice. R studio visualization code. library(latticeExtra) # Program 1 - edcfplot displays of Cumulative Distribution

I need the following examples solved in library(grid) instead of lattice.

R studio visualization code.

library(latticeExtra)

# Program 1 - edcfplot displays of Cumulative Distribution Functions

data(singer, package = "lattice") ecdfplot(~height | voice.part, data = singer)

# Program 2 - segplot - drawing segments

data(USCancerRates) segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male, data = subset(USCancerRates, state == "Washington"))

segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male, data = subset(USCancerRates, state == "Washington"), draw.bands = FALSE, centers = rate.male)

segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male, data = subset(USCancerRates, state == "Washington"), level = rate.female, col.regions = terrain.colors)

segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male, data = subset(USCancerRates, state == "Washington"), draw.bands = FALSE, centers = rate.male, segments.fun = panel.arrows, ends = "both", angle = 90, length = 1, unit = "mm")

# Program 3 panel.xyarea - cutting graph

xyplot(sunspot.year, panel = panel.xyarea, origin = 0, aspect = "xy", cut = list(n = 4, overlap = 0))

-----------

library(lattice)

xyplot(mpg ~ disp | factor(gear), data=mtcars)

# Program 2 Control of panels leyout

# aspect - adjusting panels size

xyplot(mpg ~ disp | factor(gear), data=mtcars, layout=c(3, 1),aspect="fill")

xyplot(mpg ~ disp | factor(gear), data=mtcars, layout=c(3, 1),aspect=1)

# Program 3 Different charts in separate panels

plot1 <- xyplot(mpg ~ disp, data=mtcars, aspect=1, xlim=c(65, 480), ylim=c(9, 35), subset=gear == 5) plot2 <- xyplot(mpg ~ disp, data=mtcars, aspect=1, xlim=c(65, 480), ylim=c(9, 35), subset=gear == 4) plot3 <- xyplot(mpg ~ disp, data=mtcars, aspect=1, xlim=c(65, 480), ylim=c(9, 35), subset=gear == 3) print(plot1, position=c(0, 2/3, 1, 1), more=TRUE) print(plot2, position=c(0, 1/3, 1, 2/3), more=TRUE) print(plot3, position=c(0, 0, 1, 1/3))

#position - panel localization in graphical window - arguments (left, bottom,right, top).

# Program 4 Scaterplot with grouping

gear.f<-factor((mtcars$gear), labels=c("3gears","4gears","5gears"))

xyplot(mpg ~ disp, data=mtcars, group=gear.f,auto.key=list(border=TRUE))

xyplot(mpg ~ disp, data=mtcars, group=gear.f,auto.key=list(border=TRUE), par.settings=list(superpose.symbol=list(pch=c(2, 3, 16))))

# ustawienie auto.key=list(border=TRUE) wprowadza legend? do wykresu

# Program 5 Changing axes annotation

xyplot(mpg ~ disp | factor(gear), data=mtcars, layout=c(3, 1), aspect=1, scales=list(y=list(at=seq(10, 30, 10))), ylab="miles per gallon", xlab=expression(paste("displacement (", inch^3, ")")))

# Program 6 scaterplot with regression line

xyplot(mpg ~ disp | factor(gear), data=mtcars, layout=c(3, 1), aspect=2, panel=function(x, y) { panel.lmline(x, y) panel.xyplot(x, y) })

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students explore these related Databases questions