Description Usage Arguments Value Author(s) See Also Examples
Extract first / last object
1 2 3 |
x |
|
object
of same mode
as x
Thomas P. Harte
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # from the following phrases
str<- c("hello there", "how are you?")
cat(paste(str), sep="\n")
# extract the first words:
sapply(strsplit(str, " "), first)
# extract the last words:
sapply(strsplit(str, " "), last)
# in fact this is a very useful idiom, e.g. with stock tickers:
tickers<- c("INDU Index", "USD Curncy")
cat(paste(tickers), sep="\n")
short.tickers<- sapply(strsplit(tickers, " "), first)
short.tickers
category<- sapply(strsplit(tickers, " "), last)
category
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.