Convert the ‘Name’ (passenger name) variable to a ‘character’ variable, and store it in the dataframe.
How many observations of ‘Age’ are missing from the dataframe?
Make a new variable called ‘Status’, based on the ‘Survived’ variable already in the dataset. For passengers that did not survive, Status should be ‘dead’, for those who did, Status should be ‘alive’. Make sure this new variable is a factor.
Count the number of passengers in each class.
Using grep, 1nd the six passengers with the last name ‘Fortune’.
For what proportion of the passengers is the age unknown? Was this proportion higher for 3rd class than 1st and 2nd?
titanic <- read.table("titanic.txt", header=TRUE)
str(titanic)
## 'data.frame': 1313 obs. of 5 variables:
## $ Name : Factor w/ 1310 levels "Abbing, Mr Anthony",..: 22 25 26 27 24 31 45 46 50 54 ...
## $ PClass : Factor w/ 3 levels "1st","2nd","3rd": 1 1 1 1 1 1 1 1 1 1 ...
## $ Age : num 29 2 30 25 0.92 47 63 39 58 71 ...
## $ Sex : Factor w/ 2 levels "female","male": 1 1 2 1 2 2 1 2 1 2 ...
## $ Survived: int 1 0 0 0 1 1 1 0 1 0 ...
titanic$Name <- as.character(titanic$Name)
sum(is.na(titanic$Age))
## [1] 557
titanic$status <- factor(ifelse(titanic$Survived == 1, "alive", "dead"))
table(titanic$PClass)
##
## 1st 2nd 3rd
## 322 280 711
titanic$Name[grep("Fortune",titanic$Name)]
## [1] "Fortune, Miss Alice Elizabeth"
## [2] "Fortune, Mr Charles Alexander"
## [3] "Fortune, Miss Ethel Flora"
## [4] "Fortune, Miss Mabel"
## [5] "Fortune, Mr Mark"
## [6] "Fortune, Mrs Mark (Mary McDougald)"
titanic2 <- subset(titanic, is.na(Age))
nrow(titanic2)/nrow(titanic)
## [1] 0.4242193
table(titanic2$PClass)
##
## 1st 2nd 3rd
## 96 68 393
Read the data and look at various summaries of the dataset.
From these summaries, 1nd out how many missing values there are for height and diameter.
Inspect the levels of the treatment (treat), with the levels function. Also count the number of levels with the nlevels function. Now assign new levels to the factor, replacing the abbreviations with a more informative label.
Using table, count the number of observations by treat, to check if the dataset is balanced. Be aware that table simply counts the number of rows, regardless of missing values. Now take a subset of the dataset where height is not missing, and check the number of observations again.
For which dates do missing values occur in height in this dataset?
hfe <- read.csv("HFEIFplotmeans.csv")
summary(hfe)
## plotnr Date diameter height treat
## Min. : 1.00 1/1/2008 : 16 Min. : 0.460 Min. : 1.754 C :80
## 1st Qu.: 7.75 1/1/2009 : 16 1st Qu.: 2.744 1st Qu.: 3.120 F :80
## Median :12.50 10/1/2007: 16 Median : 5.497 Median : 4.904 I :80
## Mean :12.94 10/1/2008: 16 Mean : 6.658 Mean : 6.248 IL:80
## 3rd Qu.:18.25 11/1/2007: 16 3rd Qu.:10.311 3rd Qu.: 8.504
## Max. :25.00 12/1/2007: 16 Max. :16.915 Max. :17.023
## (Other) :224 NA's :48 NA's :48
str(hfe)
## 'data.frame': 320 obs. of 5 variables:
## $ plotnr : int 1 1 1 1 1 1 1 1 1 1 ...
## $ Date : Factor w/ 20 levels "1/1/2008","1/1/2009",..: 3 13 7 5 15 2 6 17 1 19 ...
## $ diameter: num NA 3.96 7.38 NA 4.36 ...
## $ height : num NA 4.05 6.18 NA 4.22 ...
## $ treat : Factor w/ 4 levels "C","F","I","IL": 4 4 4 4 4 4 4 4 4 4 ...
library(Hmisc)
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Loading required package: ggplot2
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
##
## format.pval, round.POSIXt, trunc.POSIXt, units
describe(hfe)
## hfe
##
## 5 Variables 320 Observations
## ---------------------------------------------------------------------------
## plotnr
## n missing distinct Info Mean Gmd .05 .10
## 320 0 16 0.996 12.94 8.754 1.00 2.00
## .25 .50 .75 .90 .95
## 7.75 12.50 18.25 24.00 25.00
##
## Value 1 2 3 7 8 9 10 11 14 15
## Frequency 20 20 20 20 20 20 20 20 20 20
## Proportion 0.062 0.062 0.062 0.062 0.062 0.062 0.062 0.062 0.062 0.062
##
## Value 16 17 22 23 24 25
## Frequency 20 20 20 20 20 20
## Proportion 0.062 0.062 0.062 0.062 0.062 0.062
## ---------------------------------------------------------------------------
## Date
## n missing distinct
## 320 0 20
##
## 1/1/2008 (16, 0.05), 1/1/2009 (16, 0.05), 10/1/2007 (16, 0.05), 10/1/2008
## (16, 0.05), 11/1/2007 (16, 0.05), 12/1/2007 (16, 0.05), 12/1/2008 (16,
## 0.05), 12/1/2009 (16, 0.05), 2/1/2010 (16, 0.05), 3/1/2008 (16, 0.05),
## 3/1/2009 (16, 0.05), 3/1/2010 (16, 0.05), 4/1/2008 (16, 0.05), 4/15/2012
## (16, 0.05), 5/1/2008 (16, 0.05), 6/1/2011 (16, 0.05), 7/1/2008 (16, 0.05),
## 7/1/2009 (16, 0.05), 9/1/2008 (16, 0.05), 9/1/2010 (16, 0.05)
## ---------------------------------------------------------------------------
## diameter
## n missing distinct Info Mean Gmd .05 .10
## 272 48 269 1 6.658 4.936 1.265 1.933
## .25 .50 .75 .90 .95
## 2.744 5.498 10.311 12.752 14.824
##
## lowest : 0.4600000 0.5760000 0.7375000 0.7542857 0.7866667
## highest: 15.9183908 16.2802632 16.5278571 16.6898734 16.9146667
## ---------------------------------------------------------------------------
## height
## n missing distinct Info Mean Gmd .05 .10
## 272 48 272 1 6.248 4.11 2.248 2.687
## .25 .50 .75 .90 .95
## 3.120 4.904 8.504 11.605 14.079
##
## lowest : 1.754000 1.814000 1.848333 1.854286 1.868571
## highest: 16.163628 16.297143 16.423308 16.745879 17.022907
## ---------------------------------------------------------------------------
## treat
## n missing distinct
## 320 0 4
##
## Value C F I IL
## Frequency 80 80 80 80
## Proportion 0.25 0.25 0.25 0.25
## ---------------------------------------------------------------------------
sum(is.na(hfe$diameter))
## [1] 48
sum(is.na(hfe$height))
## [1] 48
levels(hfe$treat)
## [1] "C" "F" "I" "IL"
nlevels(hfe$treat)
## [1] 4
levels(hfe$treat) <- c("control","fertilized", "irrigated", "lf and irrigation")
table(hfe$treat)
##
## control fertilized irrigated lf and irrigation
## 80 80 80 80
hfe_1 <- subset(hfe, !is.na(height))
table(hfe_1$treat)
##
## control fertilized irrigated lf and irrigation
## 68 68 68 68
hfe$Date[unique(is.na(hfe$height), hfe$Date)]
## [1] 10/1/2007 12/1/2008 11/1/2007 5/1/2008 1/1/2009 12/1/2007 7/1/2008
## [8] 1/1/2008 9/1/2008 7/1/2009 3/1/2008 10/1/2008 12/1/2009 4/15/2012
## [15] 3/1/2010 2/1/2010 3/1/2009 9/1/2010 6/1/2011 4/1/2008 9/1/2008
## [22] 3/1/2008 10/1/2008 10/1/2007 12/1/2008 11/1/2007 5/1/2008 4/15/2012
## [29] 12/1/2007 7/1/2008 1/1/2008 9/1/2010 7/1/2009 6/1/2011 2/1/2010
## [36] 12/1/2009 1/1/2009 3/1/2010 3/1/2009 3/1/2008 10/1/2007 4/1/2008
## [43] 12/1/2007 11/1/2007 1/1/2008 9/1/2008 7/1/2009 6/1/2011 10/1/2008
## [50] 4/15/2012 12/1/2008 2/1/2010 5/1/2008 1/1/2009 3/1/2010 7/1/2008
## [57] 3/1/2009 9/1/2010 12/1/2007 7/1/2008 3/1/2009 1/1/2008 9/1/2008
## [64] 7/1/2009 3/1/2008 10/1/2008 10/1/2007 4/1/2008 12/1/2008 11/1/2007
## [71] 5/1/2008 1/1/2009 3/1/2010 6/1/2011 9/1/2010 12/1/2009 4/15/2012
## [78] 2/1/2010 7/1/2008 1/1/2008 9/1/2008 4/1/2008 3/1/2008 11/1/2007
## [85] 5/1/2008 12/1/2007 3/1/2010 3/1/2009 9/1/2010 10/1/2007 7/1/2009
## [92] 6/1/2011 10/1/2008 4/15/2012 12/1/2008 2/1/2010 1/1/2009 1/1/2008
## [99] 11/1/2007 12/1/2007 7/1/2008 3/1/2009 9/1/2008 7/1/2009 3/1/2008
## [106] 9/1/2010 10/1/2007 4/1/2008 12/1/2008 2/1/2010 5/1/2008 1/1/2009
## [113] 3/1/2010 6/1/2011 10/1/2008 12/1/2009 4/15/2012 7/1/2008 3/1/2009
## [120] 1/1/2008 9/1/2008 4/1/2008 12/1/2008 11/1/2007 5/1/2008 12/1/2007
## [127] 3/1/2010 3/1/2008 9/1/2010 10/1/2007 7/1/2009 10/1/2008 4/15/2012
## [134] 2/1/2010 1/1/2009 6/1/2011 12/1/2009 4/1/2008 11/1/2007 5/1/2008
## [141] 9/1/2008 12/1/2007 3/1/2008 10/1/2008 10/1/2007 12/1/2008 2/1/2010
## [148] 1/1/2008 1/1/2009 3/1/2010 7/1/2008 9/1/2010 7/1/2009 6/1/2011
## [155] 12/1/2009 3/1/2009 7/1/2008 1/1/2008 4/1/2008 11/1/2007 12/1/2007
## [162] 3/1/2009 9/1/2008 3/1/2010 3/1/2008 9/1/2010 10/1/2007 4/15/2012
## [169] 12/1/2008 2/1/2010 5/1/2008 1/1/2009 7/1/2009 6/1/2011 10/1/2008
## [176] 12/1/2009 12/1/2007 7/1/2008 3/1/2009 1/1/2008 10/1/2007 4/1/2008
## [183] 12/1/2008 11/1/2007 5/1/2008 1/1/2009 3/1/2010 3/1/2008 9/1/2010
## [190] 9/1/2008 7/1/2009 10/1/2008 12/1/2009 2/1/2010 6/1/2011 7/1/2008
## [197] 4/1/2008 11/1/2007 5/1/2008 12/1/2007 3/1/2009 1/1/2008 9/1/2008
## [204] 3/1/2010 3/1/2008 10/1/2008 10/1/2007 4/15/2012 12/1/2008 2/1/2010
## [211] 9/1/2010 1/1/2009 7/1/2009 6/1/2011 12/1/2009 11/1/2007 12/1/2007
## [218] 7/1/2008 3/1/2008 1/1/2008 10/1/2007 4/1/2008 12/1/2008 2/1/2010
## [225] 5/1/2008 1/1/2009 3/1/2010 3/1/2009 9/1/2010 9/1/2008 7/1/2009
## [232] 6/1/2011 10/1/2008 12/1/2009 4/15/2012 11/1/2007 3/1/2008 10/1/2007
## [239] 4/1/2008 12/1/2008 5/1/2008 12/1/2007 2/1/2010 1/1/2008 9/1/2008
## [246] 7/1/2009 6/1/2011 10/1/2008 12/1/2009 4/15/2012 3/1/2010 7/1/2008
## [253] 3/1/2009 9/1/2010 4/1/2008 12/1/2008 11/1/2007 5/1/2008 9/1/2008
## [260] 7/1/2009 3/1/2008 10/1/2008 10/1/2007 4/15/2012 12/1/2007 2/1/2010
## [267] 1/1/2008 1/1/2009 7/1/2008 9/1/2010 6/1/2011 12/1/2009 3/1/2010
## [274] 3/1/2009 4/1/2008 11/1/2007 9/1/2008 3/1/2008 10/1/2007 12/1/2008
## [281] 5/1/2008 4/15/2012 12/1/2007 2/1/2010 1/1/2008 9/1/2010 7/1/2009
## [288] 6/1/2011 10/1/2008 1/1/2009 3/1/2010 7/1/2008 3/1/2009 10/1/2007
## [295] 4/1/2008 12/1/2008 11/1/2007 1/1/2008 9/1/2008 7/1/2009 3/1/2008
## [302] 10/1/2008 12/1/2009 4/15/2012 12/1/2007 2/1/2010 5/1/2008 1/1/2009
## [309] 7/1/2008 3/1/2009 9/1/2010 6/1/2011 3/1/2010
## 20 Levels: 1/1/2008 1/1/2009 10/1/2007 10/1/2008 11/1/2007 ... 9/1/2010
Read the dataframe. Rename the 1rst column to ’DateTime.
Convert DateTime to a POSIXct class. Beware of the formatting.
Did the above action produce any missing values? Were these already missing in the original dataset?
Add a variable to the dataset called ‘Quality’. This variable should be ‘bad’ when the variable ‘ustar’ is less than 0.15, and ‘good’ otherwise.
Add a ‘month’ column to the dataset, as well as ‘year’.
Look at the ‘Rain’ column. There are some problems; re-read the data or 1nd another way to display NA whenever the data have an invalid value.
flux <- read.csv("Fluxtower.csv")
names(flux)[1] <- "DateTime"
library(lubridate)
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
summary(flux)
## DateTime FCO2 FH2O
## 23-2-09 22:00: 1 Min. :-12.3787 Min. :-0.30250
## 23-2-09 22:30: 1 1st Qu.: -3.7134 1st Qu.: 0.01125
## 23-2-09 23:00: 1 Median : 0.2137 Median : 0.13100
## 23-2-09 23:30: 1 Mean : -0.9284 Mean : 0.63313
## 24-2-09 0:00 : 1 3rd Qu.: 1.8942 3rd Qu.: 1.25965
## (Other) :229 Max. : 8.4081 Max. : 4.00600
## NA's : 10 NA's :33 NA's :33
## ustar Tair RH Tsoil
## Min. :0.0233 Min. : 0.055 Min. :20.53 Min. :-4.220
## 1st Qu.:0.0956 1st Qu.: 4.194 1st Qu.:55.40 1st Qu.: 5.899
## Median :0.1784 Median : 7.742 Median :71.68 Median : 8.233
## Mean :0.2478 Mean : 8.245 Mean :67.43 Mean : 8.156
## 3rd Qu.:0.3700 3rd Qu.:11.289 3rd Qu.:82.12 3rd Qu.:10.104
## Max. :0.7530 Max. :18.453 Max. :96.83 Max. :17.087
## NA's :33 NA's :10 NA's :10 NA's :10
## Rain
## #DIV/0!: 44
## 0 :190
## NA's : 10
##
##
##
##
flux$DateTime <- dmy_hm(flux$DateTime)
sum(is.na(flux$DateTime))
## [1] 10
flux$Quality <- factor(ifelse(flux$ustar < 0.15, "bad", "good"))
flux$month <- month(flux$DateTime)
flux$year <- year(flux$DateTime)
?read.table
## starting httpd help server ...
## done
flux <- read.csv("Fluxtower.csv", na.strings = "#DIV/0!")
Find the most frequent word used in the lyrics. To do this, 1rst paste all lyrics together into one string, then split the string into words, remove commas, then count the words.
lyric <- readLines("alphabet.txt")
nchar(lyric)
## [1] 42 39 40 46 40 44 41 40 50 37 30 42 41 42 37 51 31 42 49 41 39 36 45
## [24] 42 37 45 37 40 39 48 36 40 43 48 34 32 38 39 35 37 27 28 31 44 45 44
## [47] 39 37 39 35 38 51
lyric1 <- substr(lyric, 1, 1)
lyric2 <- sort(lyric1)
lyric1 == lyric2
## [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [12] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [23] FALSE TRUE FALSE TRUE FALSE FALSE TRUE TRUE TRUE TRUE TRUE
## [34] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [45] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
sum(lyric1 == lyric2)
## [1] 48
corpus <- paste(lyric)
corpus <- strsplit(corpus, " ")
gsub(",","", corpus)
## [1] "c(\"Artificial\" \"amateurs\" \"aren't\" \"at\" \"all\" \"amazing\")"
## [2] "c(\"Analytically\" \"I\" \"assault\" \"animate\" \"things\")"
## [3] "c(\"Broken\" \"barriers\" \"bounded\" \"by\" \"the\" \"bomb\" \"beat\")"
## [4] "c(\"Buildings\" \"are\" \"broken\" \"basically\" \"I'm\" \"bombarding\")"
## [5] "c(\"Casually\" \"create\" \"catastrophes\" \"casualties\")"
## [6] "c(\"Canceling\" \"cats\" \"got\" \"their\" \"canopies\" \"collapsing\")"
## [7] "c(\"Detonate\" \"a\" \"dime\" \"of\" \"dank\" \"daily\" \"doing\" \"dough\")"
## [8] "c(\"Demonstrations\" \"Don\" \"Dada\" \"on\" \"the\" \"down\" \"low\")"
## [9] "c(\"Eating\" \"other\" \"editors\" \"with\" \"each\" \"and\" \"every\" \"energetic\")"
## [10] "c(\"Epileptic\" \"episode\" \"elevated\" \"etiquette\")"
## [11] "c(\"Furious\" \"fat\" \"fabulous\" \"fantastic\")"
## [12] "c(\"Flurries\" \"of\" \"funk\" \"felt\" \"feeding\" \"the\" \"fanatics\")"
## [13] "c(\"Gift\" \"got\" \"great\" \"global\" \"goods\" \"gone\" \"glorious\")"
## [14] "c(\"Getting\" \"godly\" \"in\" \"his\" \"game\" \"with\" \"the\" \"goriest\")"
## [15] "c(\"Hit\" \"em\" \"high\" \"hella\" \"height\" \"historical\")"
## [16] "c(\"Hey\" \"holocaust\" \"hints\" \"hear\" \"'em\" \"holler\" \"at\" \"your\" \"homeboy\")"
## [17] "c(\"Imitators\" \"idolize\" \"I\" \"intimidate\")"
## [18] "c(\"In\" \"an\" \"instant\" \"I'll\" \"rise\" \"in\" \"an\" \"irate\" \"state\")"
## [19] "c(\"Juiced\" \"on\" \"my\" \"jams\" \"like\" \"jheri\" \"curls\" \"jocking\" \"joints\")"
## [20] "c(\"Justly\" \"it's\" \"just\" \"me\" \"writing\" \"my\" \"journals\")"
## [21] "c(\"Kindly\" \"I'm\" \"kindling\" \"all\" \"kinds\" \"of\" \"ink\" \"on\")"
## [22] "c(\"Karate\" \"kick\" \"type\" \"brits\" \"in\" \"my\" \"kingdom\")"
## [23] "c(\"Let\" \"me\" \"live\" \"a\" \"long\" \"life\" \"lyrically\" \"lessons\" \"is\")"
## [24] "c(\"Learned\" \"lame\" \"louses\" \"just\" \"lose\" \"to\" \"my\" \"livery\")"
## [25] "c(\"My\" \"mind\" \"makes\" \"marvelous\" \"moves\" \"masses\")"
## [26] "c(\"Marvel\" \"and\" \"move\" \"many\" \"mock\" \"what\" \"I've\" \"mastered\")"
## [27] "c(\"Niggas\" \"nap\" \"knowing\" \"I'm\" \"nice\" \"naturally\")"
## [28] "c(\"Knack\" \"never\" \"lack\" \"make\" \"noise\" \"nationally\")"
## [29] "c(\"Operation\" \"opposition\" \"off\" \"not\" \"optional\")"
## [30] "c(\"Out\" \"of\" \"sight\" \"out\" \"of\" \"mind\" \"wide\" \"beaming\" \"opticals\")"
## [31] "c(\"Perfected\" \"poem\" \"powerful\" \"punch\" \"lines\")"
## [32] "c(\"Pummeling\" \"petty\" \"powder\" \"puffs\" \"in\" \"my\" \"prime\")"
## [33] "c(\"Quite\" \"quaint\" \"quotes\" \"keep\" \"quiet\" \"it's\" \"Quantum\")"
## [34] "c(\"Quarrelers\" \"ain't\" \"got\" \"a\" \"quarter\" \"of\" \"what\" \"we\" \"got\" \"uh\")"
## [35] "c(\"Really\" \"raw\" \"raps\" \"rising\" \"up\" \"rapidly\")"
## [36] "c(\"Riding\" \"the\" \"rushing\" \"radioactivity\")"
## [37] "c(\"Super\" \"scientifical\" \"sound\" \"search\" \"sought\")"
## [38] "c(\"Silencing\" \"super\" \"fire\" \"saps\" \"that\" \"are\" \"soft\")"
## [39] "c(\"Tales\" \"ten\" \"times\" \"talented\" \"too\" \"tough\")"
## [40] "c(\"Take\" \"that\" \"challengers\" \"get\" \"a\" \"tune\" \"up\")"
## [41] "c(\"Universal\" \"unique\" \"untouched\")"
## [42] "c(\"Unadulterated\" \"the\" \"raw\" \"uncut\")"
## [43] "c(\"Verb\" \"vice\" \"lord\" \"victorious\" \"valid\")"
## [44] "c(\"Violate\" \"vibes\" \"that\" \"are\" \"vain\" \"make\" \"em\" \"vanished\")"
## [45] "c(\"While\" \"I'm\" \"all\" \"well\" \"what\" \"a\" \"wise\" \"wordsmith\" \"just\")"
## [46] "c(\"Weaving\" \"up\" \"words\" \"weeded\" \"up\" \"on\" \"my\" \"work\" \"shift\")"
## [47] "c(\"Xerox\" \"my\" \"X-radiation\" \"holes\" \"extra\" \"large\")"
## [48] "c(\"X-height\" \"letters\" \"and\" \"xylophone\" \"tones\")"
## [49] "c(\"Yellow\" \"back\" \"yak\" \"mouth\" \"young\" \"ones\" \"yaws\")"
## [50] "c(\"Yesterday's\" \"lawn\" \"yard\" \"sell\" \"our\" \"yawn\")"
## [51] "c(\"Zig\" \"zag\" \"zombies\" \"zoom\" \"in\" \"to\" \"the\" \"zenith\")"
## [52] "c(\"Zero\" \"in\" \"zen\" \"thoughts\" \"overzealous\" \"rhyme\" \"ZEALOTS!...\")"
unlist(corpus)
## [1] "Artificial" "amateurs," "aren't"
## [4] "at" "all" "amazing"
## [7] "Analytically," "I" "assault,"
## [10] "animate" "things" "Broken"
## [13] "barriers" "bounded" "by"
## [16] "the" "bomb" "beat"
## [19] "Buildings" "are" "broken,"
## [22] "basically" "I'm" "bombarding"
## [25] "Casually" "create" "catastrophes,"
## [28] "casualties" "Canceling" "cats"
## [31] "got" "their" "canopies"
## [34] "collapsing" "Detonate" "a"
## [37] "dime" "of" "dank"
## [40] "daily" "doing" "dough"
## [43] "Demonstrations," "Don" "Dada"
## [46] "on" "the" "down"
## [49] "low" "Eating" "other"
## [52] "editors" "with" "each"
## [55] "and" "every" "energetic"
## [58] "Epileptic" "episode," "elevated"
## [61] "etiquette" "Furious" "fat"
## [64] "fabulous" "fantastic" "Flurries"
## [67] "of" "funk" "felt"
## [70] "feeding" "the" "fanatics"
## [73] "Gift" "got" "great"
## [76] "global" "goods" "gone"
## [79] "glorious" "Getting" "godly"
## [82] "in" "his" "game"
## [85] "with" "the" "goriest"
## [88] "Hit" "em" "high,"
## [91] "hella" "height," "historical"
## [94] "Hey" "holocaust" "hints"
## [97] "hear" "'em" "holler"
## [100] "at" "your" "homeboy"
## [103] "Imitators" "idolize," "I"
## [106] "intimidate" "In" "an"
## [109] "instant," "I'll" "rise"
## [112] "in" "an" "irate"
## [115] "state" "Juiced" "on"
## [118] "my" "jams" "like"
## [121] "jheri" "curls" "jocking"
## [124] "joints" "Justly," "it's"
## [127] "just" "me," "writing"
## [130] "my" "journals" "Kindly"
## [133] "I'm" "kindling" "all"
## [136] "kinds" "of" "ink"
## [139] "on" "Karate" "kick"
## [142] "type" "brits" "in"
## [145] "my" "kingdom" "Let"
## [148] "me" "live" "a"
## [151] "long" "life," "lyrically"
## [154] "lessons" "is" "Learned"
## [157] "lame" "louses" "just"
## [160] "lose" "to" "my"
## [163] "livery" "My" "mind"
## [166] "makes" "marvelous" "moves,"
## [169] "masses" "Marvel" "and"
## [172] "move," "many" "mock"
## [175] "what" "I've" "mastered"
## [178] "Niggas" "nap" "knowing"
## [181] "I'm" "nice" "naturally"
## [184] "Knack," "never" "lack,"
## [187] "make" "noise" "nationally"
## [190] "Operation," "opposition," "off"
## [193] "not" "optional" "Out"
## [196] "of" "sight," "out"
## [199] "of" "mind," "wide"
## [202] "beaming" "opticals" "Perfected"
## [205] "poem," "powerful" "punch"
## [208] "lines" "Pummeling" "petty"
## [211] "powder" "puffs" "in"
## [214] "my" "prime" "Quite"
## [217] "quaint" "quotes" "keep"
## [220] "quiet" "it's" "Quantum"
## [223] "Quarrelers" "ain't" "got"
## [226] "a" "quarter" "of"
## [229] "what" "we" "got"
## [232] "uh" "Really" "raw"
## [235] "raps," "rising" "up"
## [238] "rapidly" "Riding" "the"
## [241] "rushing" "radioactivity" "Super"
## [244] "scientifical" "sound" "search"
## [247] "sought" "Silencing" "super"
## [250] "fire" "saps" "that"
## [253] "are" "soft" "Tales"
## [256] "ten" "times" "talented,"
## [259] "too" "tough" "Take"
## [262] "that," "challengers," "get"
## [265] "a" "tune" "up"
## [268] "Universal," "unique" "untouched"
## [271] "Unadulterated," "the" "raw"
## [274] "uncut" "Verb" "vice"
## [277] "lord" "victorious" "valid"
## [280] "Violate" "vibes" "that"
## [283] "are" "vain" "make"
## [286] "em" "vanished" "While"
## [289] "I'm" "all" "well"
## [292] "what" "a" "wise"
## [295] "wordsmith" "just" "Weaving"
## [298] "up" "words," "weeded"
## [301] "up" "on" "my"
## [304] "work" "shift" "Xerox,"
## [307] "my" "X-radiation" "holes"
## [310] "extra" "large" "X-height"
## [313] "letters," "and" "xylophone"
## [316] "tones" "Yellow" "back,"
## [319] "yak" "mouth," "young"
## [322] "ones" "yaws" "Yesterday's"
## [325] "lawn" "yard" "sell"
## [328] "our" "yawn" "Zig"
## [331] "zag" "zombies," "zoom"
## [334] "in" "to" "the"
## [337] "zenith" "Zero" "in"
## [340] "zen" "thoughts," "overzealous"
## [343] "rhyme" "ZEALOTS!..."
Make a random DNA sequence, consisting of a 100 random selections of the letters C,A,G,T, and paste the result together into one character string.
set.seed(123)
dna <- c("c","a","g", "t")
dna100 <- sample(dna, size=100, replace=TRUE)
paste(dna100)
## [1] "a" "t" "a" "t" "t" "c" "g" "t" "g" "a" "t" "a" "g" "g" "c" "t" "c"
## [18] "c" "a" "t" "t" "g" "g" "t" "g" "g" "g" "g" "a" "c" "t" "t" "g" "t"
## [35] "c" "a" "t" "c" "a" "c" "c" "a" "a" "a" "c" "c" "c" "a" "a" "t" "c"
## [52] "a" "t" "c" "g" "c" "c" "t" "t" "a" "g" "c" "a" "a" "t" "a" "t" "t"
## [69] "t" "a" "t" "g" "g" "c" "a" "c" "a" "g" "a" "c" "c" "g" "a" "t" "c"
## [86] "a" "t" "t" "t" "c" "c" "g" "a" "g" "a" "c" "t" "c" "a" "g"