Ex1a & 1b
Ex1a & 1b
Aim:
To study about various R Commands and their purpose.
Description:
Command: help()
Purpose : Obtain documentation for a given R command
Command: str()
Purpose : Display internal structure of an R object
Command: View()
Purpose : View dataset in a spreadsheet-type format
Command: dim()
Purpose : See dimensions (# of rows/cols) of data.frame
Command: length()
Purpose : Give length of a vector
Command: names()
Purpose : Lists names of variables in a data.frame
Command: hist()
Purpose : Command for producing a histogram
Command: barplot()
Purpose : Produces a bar graph
Command: barchart()
Purpose : Lattice command for producing bar graphs
Command: boxplot()
Purpose : Produces a boxplot
Command: Plot()
Purpose : Produces a scatterplot
Command: sum()
Purpose : Add up all values in a vector
Command: cut()
Purpose : Groups values of a variable into larger bins
Command: summary()
Purpose : Display 5-number summary and mean
Result:
Thus the various commands in R has been executed successfully.
Ex.No.1b Basic Data Analytic Methods using R
Aim:
To analyze the diamond dataset using Exploratory and Descriptive Statistics Methods.
Problem Statement:
The diamond dataset contains the prices and other attributes of almost 54,000 diamonds and is
included in the ggplot2 package. Use the methods of descriptive statistics and exploratory
analysis, to visualize and analyze the data.
Content
price price in US dollars (\$326--\$18,823)
carat weight of the diamond (0.2--5.01)
cut quality of the cut (Fair, Good, Very Good, Premium, Ideal)
color diamond colour, from J (worst) to D (best)
clarity a measurement of how clear the diamond is (I1 (worst), SI2, SI1, VS2, VS1,
VVS2,VVS1, IF (best))
x length in mm (0--10.74) ,y width in mm (0--58.9)
z depth in mm (0--31.8) ,depth total depth percentage = z / mean(x, y) = 2 * z / (x + y) (43--79) ,
table width of top of diamond relative to widest point (43--95)
Algorithm:
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.1.3
data(diamonds)
View(diamonds)
nrow(diamonds)
ncol(diamonds)
levels(diamonds$color)
ggplot(diamonds,aes(x=carat,y=price))+ geom_point(color='blue',fill='blue')+
xlim(0,quantile(diamonds$carat,0.99))+ylim(0,quantile(diamonds$price,0.99))+
ggtitle('Diamond price vs. carat')