lecture_06

lecture_06 - BIOS 735: Statistical Computing Michael Wu...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
BIOS 735: Statistical Computing Michael Wu Lecture 6: String Manipulation September 8, 2011 Michael Wu (Lecture 6) BIOS 735 September 8, 2011 1 / 12
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
String Manipulation R is not necessarily the best tool for doing string processing (manipulation of “character” types), but it’s often necessary: I Adjusting exported variable names to the R variable names I Changing categorical variable leveles I Processing text for use in L A T E X I Analysis of text based data I Data aquisition I Many other cases Recall that there really isn’t a “string” in R, but rather a “character” type. Michael Wu (Lecture 6) BIOS 735 September 8, 2011 2 / 12
Background image of page 2
String Manipulation: Basic Commands Coercion to a string a = 12345 b = as.character(a) String length: nchar nchar(b) British writer Susanna Clarke" nchar(a) nchar(12) nchar(1234) a = "" nchar(a) a = NA nchar(a) a = NULL nchar(a) Michael Wu (Lecture 6) BIOS 735 September 8, 2011 3 / 12
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
String Manipulation: Basic Commands Convert to UPPER/lower case: a = "UPPERlower" toupper(a) tolower(a) a = "UPPERlower3.14159_)({:;" toupper(a) Character translation: a = "butter" chartr("u","e", a) a = "BUTTER" chartr("u","e", a) old = c("BT") new = c("GN") chartr(old, new, a) chartr("T", "GN", a) chartr("TR", "N", a) Michael Wu (Lecture 6) BIOS 735 September 8, 2011 4 / 12
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

lecture_06 - BIOS 735: Statistical Computing Michael Wu...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online