Skip to content

Instantly share code, notes, and snippets.

@ZeccaLehn
Last active August 29, 2015 14:13
Show Gist options
  • Save ZeccaLehn/30eb3701bb99bd047c27 to your computer and use it in GitHub Desktop.
Save ZeccaLehn/30eb3701bb99bd047c27 to your computer and use it in GitHub Desktop.
String to Characters in R -- "Hello World" Function
stringToChar<- function( example ){
example <- as.character(example)
letters <- strsplit(example,"")[[1]]
for (i in letters[1:length(letters)] ) { print(i) }
}
## #Uncomment in IDE to run locally. Note URL match.
# library(devtools)
# source_gist("30eb3701bb99bd047c27")
# stringToChar( "Hello Wooorld!" )
# [1] "H"
# [1] "e"
# [1] "l"
# [1] "l"
# [1] "o"
# [1] " "
# [1] "W"
# [1] "o"
# [1] "o"
# [1] "o"
# [1] "r"
# [1] "l"
# [1] "d"
# [1] "!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment