0% found this document useful (0 votes)
0 views1 page

R Console

The document outlines the use of R version 4.4.1 for data analysis, specifically focusing on a dataset containing wine quality information. It includes commands to load libraries, read a CSV file, and generate various visualizations such as histograms and boxplots for different wine attributes. Additionally, it calculates and displays the average alcohol content and total row counts by wine type.

Uploaded by

Hemang Lath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views1 page

R Console

The document outlines the use of R version 4.4.1 for data analysis, specifically focusing on a dataset containing wine quality information. It includes commands to load libraries, read a CSV file, and generate various visualizations such as histograms and boxplots for different wine attributes. Additionally, it calculates and displays the average alcohol content and total row counts by wine type.

Uploaded by

Hemang Lath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

R version 4.4.

1 (2024-06-14) -- "Race for Your Life"


Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20

R is free software and comes with ABSOLUTELY NO WARRANTY.


You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.


Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or


'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[R.app GUI 1.80 (8416) aarch64-apple-darwin20]

[History restored from /Users/hemangmac/.Rapp.history]

> library(ggplot2)
> library(dplyr)

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

filter, lag

The following objects are masked from ‘package:base’:

intersect, setdiff, setequal, union

>
> dataset <- read.csv("wine-quality-white-and-red.csv")
>
> print("Column Names:")
[1] "Column Names:"
> print(colnames(dataset))
[1] "type" "fixed.acidity" "volatile.acidity" "citric.acid"
[5] "residual.sugar" "chlorides" "free.sulfur.dioxide" "total.sulfur.dioxide"
[9] "density" "pH" "sulphates" "alcohol"
[13] "quality"
>
> ggplot(data = dataset, aes(x = fixed.acidity)) +
+ geom_histogram(binwidth = 0.5, fill = "blue", color = "black") +
+ ggtitle("Histogram of Fixed Acidity")
>
> ggplot(data = dataset, aes(x = type, y = volatile.acidity)) +
+ geom_boxplot(fill = "orange", color = "black") +
+ ggtitle("Boxplot of Volatile Acidity by Type")
>
> ggplot(data = dataset, aes(x = residual.sugar)) +
+ geom_histogram(binwidth = 1, fill = "green", color = "black") +
+ ggtitle("Histogram of Residual Sugar")
>
> ggplot(data = dataset, aes(x = type, y = chlorides)) +
+ geom_boxplot(fill = "purple", color = "black") +
+ ggtitle("Boxplot of Chlorides by Type")
>
> # Plot for 'pH'
> ggplot(data = dataset, aes(x = pH)) +
+ geom_histogram(binwidth = 0.1, fill = "red", color = "black") +
+ ggtitle("Histogram of pH")
>
> # Bar chart for 'type'
> ggplot(data = dataset, aes(x = type)) +
+ geom_bar(fill = "cyan", color = "black") +
+ ggtitle("Bar Chart of Wine Type")
>
> avg_alcohol <- dataset %>%
+ group_by(type) %>%
+ summarise(avg_alcohol = mean(alcohol, na.rm = TRUE))
>
> print("Average Alcohol Content by Type:")
[1] "Average Alcohol Content by Type:"
> print(avg_alcohol)
# A tibble: 2 × 2
type avg_alcohol
<chr> <dbl>
1 red 10.4
2 white 10.5
>
> row_count <- dataset %>%
+ group_by(type) %>%
+ summarise(count = n())
>
> print("Total Number of Rows by Type:")
[1] "Total Number of Rows by Type:"
> print(row_count)
# A tibble: 2 × 2
type count
<chr> <int>
1 red 1599
2 white 4898
>
>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy