Student Name: Senet Manandhar
Data received: Built in R studi0 - cars dataset
Scatterplot in 3D:
library(openintro)
## Please visit openintro.org for free statistics materials
##
## Attaching package: 'openintro'
## The following object is masked from 'package:datasets':
##
## cars
data(cars)
View(cars)
str(cars)
## 'data.frame': 54 obs. of 6 variables:
## $ type : Factor w/ 3 levels "large","midsize",..: 3 2 2 2 2 1 1 2 1 2 ...
## $ price : num 15.9 33.9 37.7 30 15.7 20.8 23.7 26.3 34.7 40.1 ...
## $ mpgCity : int 25 18 19 22 22 19 16 19 16 16 ...
## $ driveTrain: Factor w/ 3 levels "4WD","front",..: 2 2 2 3 2 2 3 2 2 2 ...
## $ passengers: int 5 5 6 4 6 6 6 5 6 5 ...
## $ weight : int 2705 3560 3405 3640 2880 3470 4105 3495 3620 3935 ...
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.3.3
## Loading tidyverse: ggplot2
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Loading tidyverse: dplyr
## Warning: package 'ggplot2' was built under R version 3.3.3
## Warning: package 'tibble' was built under R version 3.3.3
## Warning: package 'tidyr' was built under R version 3.3.3
## Warning: package 'purrr' was built under R version 3.3.3
## Warning: package 'dplyr' was built under R version 3.3.3
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## lag(): dplyr, stats
ggplot(cars, aes(x=price, y=weight))+geom_point()
ggplot(cars, aes(x=price, y=weight, color=mpgCity))+geom_point()
ggplot(cars, aes(x=price, y=weight, z=mpgCity))+geom_point()
Download the package “Scatterplot3d”
library(scatterplot3d)
## Warning: package 'scatterplot3d' was built under R version 3.3.3
plot(cars$weight~cars$price)
scatterplot3d(cars[1:3])
scatterplot3d(cars$price, cars$weight, cars$mpgCity)
s3d<-scatterplot3d(cars$price, cars$weight, cars$mpgCity, pch=16, highlight.3d = TRUE, type="h",main="3D Scatterplot", angle = 75)
s3d<-scatterplot3d(cars$price, cars$weight, cars$mpgCity, pch=16, highlight.3d = TRUE, type="h",main="3D Scatterplot", angle = 90)
s3d<-scatterplot3d(cars$price, cars$weight, cars$mpgCity, pch=16, highlight.3d = TRUE, type="h",main="3D Scatterplot", angle = 100)
comments:
plot(cars$weight~cars$price)
a<-lm(cars$weight~cars$price)
abline(a)
s3d<-scatterplot3d(cars$price, cars$mpgCity, cars$weight,pch=16,highlight.3d = TRUE,type="h",main="3D Scatterplot", angle=30)
plane<-lm(cars$weight~cars$price+cars$mpgCity)
s3d$plane3d(plane)
library(rgl)
## Warning: package 'rgl' was built under R version 3.3.3
plot3d(cars$price, cars$mpgCity, cars$weight,pch=16,highlight.3d = TRUE,main="3D Scatterplot", type= "s", col="green", size=1)
rglwidget()