http://1drv.ms/1E1m81i
function_list.htmlort
http://www.sr.bham.ac.uk/~ajrs/R/r-functio
n_list.html
NULL:
Function is.na
Create
TRUE
Function na.fail
Function
Data
> na.fail(student_gi)
1001
1002
1003
1004
1005
Display,
not
> head(studs2014)
> is.na(studs2014[,"email"])
Display only the students with misssing e-mail
address:
> studs2014[is.na(studs2014$email),]
Display, for each observation, if variables q1:q5 are
NA in data frame leadership:
> is.na(leadership[,6:10])
q1
q2
q3
q4
q5
[1,] FALSE FALSE FALSE FALSE FALSE
[2,] FALSE FALSE FALSE FALSE FALSE
[3,] FALSE FALSE FALSE FALSE FALSE
Counting NA's
Counting
How
> sum(is.na(leadership))
[1] 2
How
> sum(is.na(comp))
Function complete.cases
Display
NA
> leadership[!complete.cases(leadership),]
manager
date country gender age q1 q2 q3
q4 q5
4
4 2000/12/10
UK
M 59 3 3 4
NA NA
> comp[!complete.cases(comp),]
Counting
TRUE
4
Using sum...
> sum(is.na(studs2014$email))
[1] 1617
...or table
> table(is.na(studs2014$email))
FALSE TRUE
4875 1617
Display,
NULLs
Completely
4 NA
> v.with.null
[1] 1 3 4 5 6
NULLs (cont.)
> length(v.with.na)
[1] 6
> length(v.with.null)
[1] 5
> sum(v.with.na)
[1] NA
> sum(v.with.null)
[1] 19
In
> names(adl2013_stud)
[1] "Nr"
"NumePren" "Matricol" "Email"
> adl2013_stud$Nr <- NULL
> names(adl2013_stud)
[1] "NumePren" "Matricol" "Email"
Base R
nchar
substr
strsplit
paste / paste0 / sprintf
Package
stringr
http://gastonsanchez.com/Handling_and_Pr
ocessing_Strings_in_R.pdf
John Myles White - Text Processing in R
http://www.johnmyleswhite.com/notebook/2
009/02/25/text-processing-in-r/
Elana J. Fertig - Processing strings with R
https://www.academia.edu/1744442/String
_processing_with_R
Regular expressions
Vital
Functions in base R:
grep, grepl,
sub, gsub,
regexpr, gregexpr
strdetect
strextract, strextractall, strmatch, strmatchall
strlocate, strlocateall
strreplace, strreplaceall
strsplit, strsplitfixed
http://www.rexegg.com/regex-quickstart
.html
http://www.r-bloggers.com/regular-expres
sion-and-associated-functions-in-r/
http://www.r-bloggers.com/r-talk-on-regu
lar-expressions-regex/
Regular Expressions
https://www.youtube.com/watch?v=NvHjY