Chapter 6 Beer, Farms , and Peas
Note
- Install R-3.5.1-win.exe on Windows 10.
- Click the shortcut R x64 3.5.1 on Desktop.
- Type command in RGui:
us <- read.DIF("clipboard",transpose=TRUE)
- Open nst-est2017-01.xlsx. You can download this file from State Population Totals and Components of Change: 2010-2017. Click the linke Annual Estimates of the Resident Population for the United States, Regions, States, and Puerto Rico: April 1, 2010 to July 1, 2017 (NST-EST2017-01) to download it.
- Select 50 states
- Copy data to clipboard with Ctrl+C
- Press Enter key to execute the read command in RGui.
- Now we can check data via type the variable name.
- Try commands:
mean(us$V2) median(us$V2) mode(us$V2) sd(us$V2) var(us$V2)
- Show hist diagram. It will show 10 bars:
hist(us)
- Show hist with breaks parameter. It will show 20 bars:
hist(us,breaks=20)
- Draw normal distribution histgram. Usage:rnorm(n,mean,sd)
hist(rnorm(50,500.7451,283.2001))