Showing posts with label barchart. Show all posts
Showing posts with label barchart. Show all posts

Saturday, August 17, 2019

Histogram in R

 How to draw the histogram in R

library("ggplot2", lib.loc="~/R/win-library/3.6")
data(mpg)
hist(mpg$cty)
histogram in r,visualizations,power bi hist,five number summary,mean,standard deviation,outliers,summary statistics,how-to (website category),rstudio (software),exploratory data analysis,john tukey,eda,data sets,rstudio,plots,power bi histogram,r;,split,stat 321,overlay normal distribution curve in r,superimpose normal distribution curve in r,normal curve on histogram,normal,hausman test stata,cointegration test eviews


> hist(mpg$cty,
+      xlab = "Miles Per Gallon (City)",
+      main = "Histogram of MPG (City)",
+      breaks = 12,
+      col = "dodgerblue",
+      border = "darkorange")

> hist(mpg$cty,
+      xlab = "Miles Per Gallon (City)",
+      main = "Histogram of MPG (City)",
+      breaks = 12,
+      col = "red",
+      border = "darkorange")
https://www.r-languagestatistics.co

How to draw bar plot-R

> Barplots
Error: object 'Barplots' not found
> barplot(table(mpg$drv))
> barplot(table(mpg$drv),
+         xlab = "Drivetrain (f = FWD, r = RWD, 4 = 4WD)",
+         ylab = "Frequency",
+         main = "Drivetrains",
+         col = "blue",
+         border = "darkorange")
> Boxplots
Error: object 'Boxplots' not found
> unique(mpg$drv)
[1] "f" "4" "r"
>
> boxplot(mpg$hwy)
> boxplot(hwy ~ drv, data = mpg)
> boxplot(hwy ~ drv, data = mpg,
+         xlab = "Drivetrain (f = FWD, r = RWD, 4 = 4WD)",
+         ylab = "Miles Per Gallon (Highway)",
+         main = "MPG (Highway) vs Drivetrain",
+         pch = 18,
+         cex = 2,
+         col = "darkorange",
+         border = "dodgerblue")
https://www.r-languagestatistics.co

 How to draw Scatterplots

> plot(hwy ~ displ, data = mpg)
> plot(hwy ~ displ, data = mpg,
+      xlab = "Engine Displacement (in Liters)",
+      ylab = "Miles Per Gallon (Highway)",
+      main = "MPG (Highway) vs Engine Displacement",
+      pch = 20,
+      cex = 6,
+      col = "blue")
> hist(mpg$cty,
+      xlab = "Miles Per Gallon (City)",
+      main = "Histogram of MPG (City)",
+      breaks = 12,
+      col = "dodgerblue",
+      border = "darkorange")
https://www.r-languagestatistics.co

Black-Scholes formula-R

 Black-Scholes formula-R > BlackScholes <- function(TypeFlag = c("c", "p"), S, X, Time, r, b, sigma) { TypeFla...