library("tidyverse")
## Warning: package 'tidyverse' was built under R version 4.4.2
## Warning: package 'ggplot2' was built under R version 4.4.2
## Warning: package 'readr' was built under R version 4.4.2
## Warning: package 'dplyr' was built under R version 4.4.2
## Warning: package 'forcats' was built under R version 4.4.2
## Warning: package 'lubridate' was built under R version 4.4.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library("ggplot2")

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

x <- rnorm(100)
y <- rnorm(100)
plot(x,y)

plot(x,y,xlab ="this is the x-axis",ylab="this is the y-axis",main='Plot of x vs y')

x
##   [1]  0.91799451  1.62079907  0.31697839 -0.33449363  0.24052104 -2.07837829
##   [7]  0.14502065 -0.70928174  1.85866967  0.14786364 -0.50087607 -0.12301013
##  [13]  0.29485638 -0.55611794  0.54937327  1.14286479 -1.81975965  0.13908065
##  [19]  1.74373884  1.45385966 -1.05702892 -1.25596284 -0.45529313  0.47910460
##  [25] -0.56674996 -1.21984292  0.25011764 -0.45554469 -0.86176928  0.10340616
##  [31] -1.30085584  0.73498451 -0.60982428 -0.03412105 -0.48305475  0.56559061
##  [37] -0.40895515  0.81015753 -0.64917569  0.22040361 -0.48220696 -1.35396199
##  [43]  0.19009270 -0.99452784  0.22897664  0.54060342 -0.23963881 -0.98283240
##  [49]  0.18755583 -0.27203193  0.06891901  0.04580179 -0.16084544 -0.26370734
##  [55] -1.72055700  1.16725857 -0.57324147 -0.06299255  1.02310915  0.29379969
##  [61] -0.37195957  1.03830304 -0.73287703 -1.08689674  0.11146179  0.22057222
##  [67] -1.01949226 -0.45517389  2.24721145 -0.91599133 -0.37199511 -1.55926229
##  [73] -0.34083387 -1.57442551  0.77166463 -0.49885294 -1.12590411  0.48415034
##  [79]  1.00658798  0.75855707 -1.50859659  0.26306651 -1.97848196 -1.28030048
##  [85] -1.24932146  0.86329992 -2.09746774 -0.50345742 -0.37693740  0.55425725
##  [91]  1.12507244  0.90555758 -0.03291652 -1.18133548 -1.65281676 -1.07988916
##  [97]  0.72223376  0.74790164  0.21898860  1.07886239
y<-x^2
plot(x,y,xlab = "this is the x-axis", ylab = "this is the y-axis", main = "plot of x vs y")

x<-x^2
y
##   [1] 0.842713914 2.626989611 0.100475301 0.111885990 0.057850369 4.319656297
##   [7] 0.021030989 0.503080591 3.454652958 0.021863655 0.250876841 0.015131493
##  [13] 0.086940283 0.309267165 0.301810986 1.306139919 3.311525181 0.019343428
##  [19] 3.040625137 2.113707906 1.117310138 1.577442666 0.207291836 0.229541215
##  [25] 0.321205513 1.488016753 0.062558836 0.207520962 0.742646289 0.010692834
##  [31] 1.692225921 0.540202229 0.371885658 0.001164246 0.233341895 0.319892741
##  [37] 0.167244313 0.656355221 0.421429080 0.048577752 0.232523556 1.833213059
##  [43] 0.036135234 0.989085620 0.052430303 0.292252063 0.057426759 0.965959518
##  [49] 0.035177188 0.074001373 0.004749830 0.002097804 0.025871255 0.069541560
##  [55] 2.960316389 1.362492561 0.328605780 0.003968061 1.046752325 0.086318256
##  [61] 0.138353921 1.078073211 0.537108748 1.181344517 0.012423730 0.048652102
##  [67] 1.039364460 0.207183267 5.049959310 0.839040117 0.138380364 2.431298901
##  [73] 0.116167730 2.478815682 0.595466300 0.248854251 1.267660073 0.234401556
##  [79] 1.013219367 0.575408827 2.275863671 0.069203987 3.914390870 1.639169325
##  [85] 1.560804106 0.745286748 4.399370929 0.253469373 0.142081800 0.307201100
##  [91] 1.265788001 0.820034532 0.001083497 1.395553527 2.731803235 1.166160594
##  [97] 0.521621599 0.559356867 0.047956008 1.163944060
plot(x,y,xlab = "this is the x-axis", ylab= "this is the y-axis",main ="Plot of x vs y", type="l")

plot(x,y,xlab = "this is the x-axis", ylab= "this is the y-axis",main ="Plot of x vs y", type="p")

plot(x,y,xlab = "this is the x-axis", ylab= "this is the y-axis",main ="Plot of x vs y", type="b")

ggplot(data=mpg) + geom_point(mapping = aes(x=displ,y=hwy))

mpg
## # A tibble: 234 × 11
##    manufacturer model      displ  year   cyl trans drv     cty   hwy fl    class
##    <chr>        <chr>      <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr>
##  1 audi         a4           1.8  1999     4 auto… f        18    29 p     comp…
##  2 audi         a4           1.8  1999     4 manu… f        21    29 p     comp…
##  3 audi         a4           2    2008     4 manu… f        20    31 p     comp…
##  4 audi         a4           2    2008     4 auto… f        21    30 p     comp…
##  5 audi         a4           2.8  1999     6 auto… f        16    26 p     comp…
##  6 audi         a4           2.8  1999     6 manu… f        18    26 p     comp…
##  7 audi         a4           3.1  2008     6 auto… f        18    27 p     comp…
##  8 audi         a4 quattro   1.8  1999     4 manu… 4        18    26 p     comp…
##  9 audi         a4 quattro   1.8  1999     4 auto… 4        16    25 p     comp…
## 10 audi         a4 quattro   2    2008     4 manu… 4        20    28 p     comp…
## # ℹ 224 more rows
ggplot(data =mpg) + geom_point(mapping = aes(x = displ, y = hwy))

ggplot(data =mpg) + geom_point(mapping = aes(x = displ, y = cty))

ggplot(data =mpg) + geom_point(mapping = aes(x = displ, y = hwy, color=class))

ggplot(data =mpg) + geom_point(mapping = aes(x = displ, y = hwy, color=manufacturer))

ggplot(data =mpg) + geom_point(mapping = aes(x = displ, y = hwy, size=class))
## Warning: Using size for a discrete variable is not advised.

ggplot(data =mpg) + geom_point(mapping = aes(x = displ, y = hwy, color="pink"))

library("tidyverse")
library("ggplot2")

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.