 str1 <- "this is "a" test"
Error: unexpected symbol in "str1 <- "this is "a"
> str1 <- "this is 'a' test"
> str1
[1] "this is 'a' test"
> str1 <- 'this is "a" test'
> str1
[1] "this is \"a\" test"
> 
> str1 <- "this is \"a\" test"
> str1
[1] "this is \"a\" test"
> a <- "an example"
> b <- 12
> is.character(a)
[1] TRUE
> is.character(b)
[1] FALSE
> class(a)
[1] "character"
> class(b)
[1] "numeric"
> c <- as.character (b)
> class(c)
[1] "character"
> c
[1] "12"
> test <- c(5.11, 1:3, "this is a test", TRUE)
> test [1]
[1] "5.11"
> test [4]
[1] "3"
> class(test)
[1] "character"
> df <- data.frame (nums = 1:3, letters = letters [1:3])
> df
  nums letters
1    1       a
2    2       b
3    3       c
> df <- data.frame (nums = 1:3, letters = LETTERS [1:3])
> df
  nums letters
1    1       A
2    2       B
3    3       C
> df <- rbind (df, c (4, LETTERS [4]))
Warning message:
In `[<-.factor`(`*tmp*`, ri, value = "D") :
  invalid factor level, NA generated
> df
  nums letters
1    1       A
2    2       B
3    3       C
4    4    <NA>
> df <- data.frame (nums = 1:3, letters = LETTERS [1:3], stringsAsFactors = FALSE)
> df <- rbind (df, c (4, LETTERS [4]))
> df
  nums letters
1    1       A
2    2       B
3    3       C
4    4       D
> chartr("a", "A", "This is a test")
[1] "This is A test"
> chartr("is", "A", "This is a test")
Error in chartr("is", "A", "This is a test") : 'old' is longer than 'new'
> chartr("is", "IS", "This is a test")
[1] "ThIS IS a teSt"
> substr("asdfghj", 2,5)
[1] "sdfg"
> substr("asdfghj", 2,2) <- "*"
Error in substr("asdfghj", 2, 2) <- "*" : 
  target of assignment expands to non-language object
> str <- "test"
> substr(str, 2,2) <- "*"
> str
[1] "t*st"
> str <- "asdfghj"
> substr(str, 2,4) <- "$$"
> str
[1] "a$$fghj"
> str <- "asdfghj"
> substr(str, 2,4) <- "$$$$"
> str
[1] "a$$$ghj"
> str <- "ASDFGH"
> substring (str, 3)
[1] "DFGH"
> strset <- c ("apple", "banana", "ball", "XYZ", "first")
> sort(strset)
[1] "apple"  "ball"   "banana" "first"  "XYZ"   
> sort(strset, decreasing = T)
[1] "XYZ"    "first"  "banana" "ball"   "apple" 
> nchar(str)
[1] 6
> library(stringr)
> str_length (str)
[1] 6
> str_length (strset)
[1] 5 6 4 3 5
> str_c ("th" , "is")
[1] "this"
> str_sub (strset, 1, 3)
[1] "app" "ban" "bal" "XYZ" "fir"
> str_to_upper (strset)
[1] "APPLE"  "BANANA" "BALL"   "XYZ"    "FIRST" 
> str_to_lower (strset)
[1] "apple"  "banana" "ball"   "xyz"    "first" 
> str_view (strset, "a")
> strset <- c ("apple2", "ample", "12ball", "XYZ", "firstA")
> str_extract (strset, "\\d")
[1] "2" NA  "1" NA  NA 
> str_view (strset, "\\d")
> str_detect (strset, "e")
[1]  TRUE  TRUE FALSE FALSE FALSE
> sum (str_detect (strset, "^a"))
[1] 2
> str_extract_all ("This is, fortunately, another good test", boundary ("word"))
[[1]]
[1] "This"        "is"          "fortunately" "another"     "good"       
[6] "test"       

> str_extract_all ("This is, fortunately, another good test", boundary ("character"))
[[1]]
 [1] "T" "h" "i" "s" " " "i" "s" "," " " "f" "o" "r" "t" "u" "n" "a" "t" "e" "l"
[20] "y" "," " " "a" "n" "o" "t" "h" "e" "r" " " "g" "o" "o" "d" " " "t" "e" "s"
[39] "t"

> 
