library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.4.2
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.2
##
## 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
library(mosaic)
## Warning: package 'mosaic' was built under R version 3.4.2
## Loading required package: lattice
## Loading required package: ggformula
## Warning: package 'ggformula' was built under R version 3.4.2
##
## New to ggformula? Try the tutorials:
## learnr::run_tutorial("introduction", package = "ggformula")
## learnr::run_tutorial("refining", package = "ggformula")
## Loading required package: mosaicData
## Warning: package 'mosaicData' was built under R version 3.4.2
## Loading required package: Matrix
##
## The 'mosaic' package masks several functions from core packages in order to add
## additional features. The original behavior of these functions should not be affected by this.
##
## Note: If you use the Matrix package, be sure to load it BEFORE loading mosaic.
##
## Attaching package: 'mosaic'
## The following object is masked from 'package:Matrix':
##
## mean
## The following objects are masked from 'package:dplyr':
##
## count, do, tally
## The following objects are masked from 'package:stats':
##
## binom.test, cor, cor.test, cov, fivenum, IQR, median,
## prop.test, quantile, sd, t.test, var
## The following objects are masked from 'package:base':
##
## max, mean, min, prod, range, sample, sum
cancer <- read.csv("Rdatasets-master/csv/survival/cancer.csv")
head(cancer)
## X inst time status age sex ph.ecog ph.karno pat.karno meal.cal wt.loss
## 1 1 3 306 2 74 1 1 90 100 1175 NA
## 2 2 3 455 2 68 1 0 90 90 1225 15
## 3 3 3 1010 1 56 1 0 90 90 NA 15
## 4 4 5 210 2 57 1 1 90 60 1150 11
## 5 5 1 883 2 60 1 0 100 90 NA 0
## 6 6 12 1022 1 74 1 1 50 80 513 0
ggplot(cancer, aes(time)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(cancer, aes(time, fill = cut(time, 100))) +
geom_histogram(show.legend = FALSE) +
scale_fill_discrete(h = c(240, 10))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

p <- ggplot(cancer, aes(time, fill = cut(time, 100))) +
geom_histogram(show.legend = FALSE) +
theme_minimal() +
labs(time = "Variable X", y = "age") +
ggtitle("Histogram of Time")
p + scale_fill_discrete(h = c(180, 360), c = 150, l = 80)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(cancer, aes(time, fill = cut(time, 100))) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

fill="chartreuse"