Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1: Emulation of R in Python Demonstrate Python analogues of the following R code blocks from the previous homework. Hints: The Python statsmodels module

Problem 1: Emulation of R in Python

Demonstrate Python analogues of the following R code blocks from the previous homework. Hints:

The Python statsmodels module includes the submodule datasets which simulates the corresponding R package.

The R pairs function can be simulated using the pandas function scatter_matrix.

The seaborn function FacetGrid allows you to set up a grid in which each entry corresponds to a particular value of a conditioning variable. Use this, and the matplotlib scatter plot functionality, to simulate the R function coplot.

The statsmodels module mosaicplot can simulate the R function mosaicplot.

1.

from statsmodels import datasets %load_ext rpy2.ipython

%%R pairs(mtcars) 

translate in to python

2.

%%R require(stats); require(graphics) coplot(circumference ~ age | Tree, data = Orange, show.given = FALSE) 

translate into python

3.

%%R x <- apply(HairEyeColor, c(1, 2), sum) x mosaicplot(x) 

translate in to python

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions