OnlineNursingOwl
← All nursing posts

Engineering · Studypool

SJSU R Code Engineering Worksheet

Overview

1.Write the R code for Lab 3 and lab 4 in files

2.Question 1

  • Use lmplot() to look at the relationship between x and y.
  • Plot a regression line .
  • Now display with multiple row
  • Now display with multiple col

Question 2

  • Use a white style for the plot.
  • Create a lmplot() comparing the two columns.
  • Remove the top and right spines using despine().

Question 3

  • Set the default Seaborn style and enable the matplotlib color codes.
  • Create a displot for the 1(any) column using matplotlib's magenta (m) color code.

Question 4

Create and display a Purples sequential palette containing 8 colors[‘Red,Purple,Green].

Create the Purples palette

for p in ['Purples','Reds','Greens']:

sns.palplot(sns.color_palette(p, 8))

plt.show()

Question 5Create a for loop to show the difference between the bright and colorblind palettes.

Set the palette using the set_palette() function.

Use a displot of (any) column

Question 6

    • Use pandas' crosstab() function to build a table of visits by x and y.
    • Print the pd_crosstab DataFrame.
    • Plot the data using Seaborn's heatmap().
    Question 7
    • Create a crosstab table of x and y
    • Create a heatmap of the data using the BuGn palette
    • Disable the cbar and increase the linewidth to 0.3