new-talk
R provides a wide variety of statistical (linear and nonlinear modelling, time-series analysis, classification, clustering etc) and graphical techniques, and is highly extensible.
The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.
Book “The Art of R Programming” http://diytranscriptomics.com/Reading/files/The%20Art%20of%20R%20Programming.pdf
Write in Console Studio
install.packages("swirl")
library("swirl")
# Follow as instructed.
## Warning: package 'ggplot2' was built under R version 3.4.3
## Warning: package 'scales' was built under R version 3.4.3
## Warning: package 'reshape2' was built under R version 3.4.3
VD 3 ========================================================
VD 4 ========================================================
VD 5 ========================================================
Facet_grid with GGPLOT2
======================================================== With Base ========================================================
Facet_grid with GGPLOT2
========================================================
#Facet grid
sp <- ggplot(tips, aes(x=total_bill, y=tip/total_bill))
sp + geom_point(shape =1)
sp + facet_grid(sex ~ day)+ geom_point(shape =1)
Facet_grid With Base ========================================================
par(mfrow=c(2,4))
days <- c("Thur", "Fri", "Sat", "Sun")
sexes <- unique(tips$sex)
for (i in 1:length(sexes)) {
for (j in 1:length(days)) {
currdata <- tips[tips$day == days[j] & tips$sex == sexes[i],]
plot(currdata$total_bill, currdata$tip/currdata$total_bill,
main=paste(days[j], sexes[i], sep=", "), ylim=c(0,0.7), las=1)
}
}
Other example A ====================================
## Warning: package 'Rcmdr' was built under R version 3.4.3
## Loading required package: splines
## Loading required package: RcmdrMisc
## Warning: package 'RcmdrMisc' was built under R version 3.4.3
## Loading required package: car
## Warning: package 'car' was built under R version 3.4.3
## Loading required package: sandwich
## Warning: package 'sandwich' was built under R version 3.4.3
## Loading required package: effects
## Warning: package 'effects' was built under R version 3.4.3
## Loading required package: carData
##
## Attaching package: 'carData'
## The following objects are masked from 'package:car':
##
## Guyer, UN, Vocab
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.
## The Commander GUI is launched only in interactive sessions
## Warning: package 'GGally' was built under R version 3.4.3
##
## Attaching package: 'dplyr'
## The following object is masked from 'package:GGally':
##
## nasa
## The following object is masked from 'package:car':
##
## recode
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## -------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## -------------------------------------------------------------------------
##
## Attaching package: 'plyr'
## The following objects are masked from 'package:dplyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
## Warning: package 'lubridate' was built under R version 3.4.3
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:plyr':
##
## here
## The following object is masked from 'package:base':
##
## date
## Warning: package 'rgl' was built under R version 3.4.3
TEXT LABEL ========================================================
CONNECTION MAP ========================================================
## Warning: package 'tidyverse' was built under R version 3.4.3
## -- Attaching packages -------------------------------------- tidyverse 1.2.1 --
## v tibble 1.3.4 v purrr 0.2.4
## v tidyr 0.7.2 v stringr 1.2.0
## v readr 1.1.1 v forcats 0.2.0
## Warning: package 'tidyr' was built under R version 3.4.3
## Warning: package 'readr' was built under R version 3.4.3
## Warning: package 'stringr' was built under R version 3.4.3
## Warning: package 'forcats' was built under R version 3.4.3
## -- Conflicts ----------------------------------------- tidyverse_conflicts() --
## x plyr::arrange() masks dplyr::arrange()
## x lubridate::as.difftime() masks base::as.difftime()
## x readr::col_factor() masks scales::col_factor()
## x purrr::compact() masks plyr::compact()
## x plyr::count() masks dplyr::count()
## x lubridate::date() masks base::date()
## x purrr::discard() masks scales::discard()
## x tidyr::extract() masks magrittr::extract()
## x plyr::failwith() masks dplyr::failwith()
## x dplyr::filter() masks stats::filter()
## x lubridate::here() masks plyr::here()
## x plyr::id() masks dplyr::id()
## x lubridate::intersect() masks base::intersect()
## x dplyr::lag() masks stats::lag()
## x plyr::mutate() masks dplyr::mutate()
## x dplyr::recode() masks car::recode()
## x plyr::rename() masks dplyr::rename()
## x purrr::set_names() masks magrittr::set_names()
## x lubridate::setdiff() masks base::setdiff()
## x purrr::some() masks car::some()
## x plyr::summarise() masks dplyr::summarise()
## x plyr::summarize() masks dplyr::summarize()
## x lubridate::union() masks base::union()
## Warning: package 'maps' was built under R version 3.4.3
##
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
##
## map
## The following object is masked from 'package:plyr':
##
## ozone
## Warning: package 'geosphere' was built under R version 3.4.3
## Rattle: A free graphical interface for data science with R.
## Version 5.1.0 Copyright (c) 2006-2017 Togaware Pty Ltd.
## Type 'rattle()' to shake, rattle, and roll your data.
## Warning: package 'ggExtra' was built under R version 3.4.3
## mpg cyl disp hp drat wt qsec vs am gear carb
## Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
## Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
## Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
## Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
## Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
## Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1
SPYWEB ========================================================
RADAR 1 ========================================================
RADAR 2 ========================================================
## Warning: package 'treemap' was built under R version 3.4.3
TREEMAP ========================================================
TREEMAP ========================================================
## Warning: package 'gsubfn' was built under R version 3.4.3
## Loading required package: proto
## Warning: package 'proto' was built under R version 3.4.3