get_name | R Documentation |
Extract symbol names (tickers) from a vector of character strings.
get_name(str_ing, sep = "[.]", field = 1)
str_ing |
A vector of character strings containing symbol names. |
sep |
The name separator, i.e. the single character
that separates the symbol name from the rest of the string (default is
" |
field |
The position of the name in the string, i.e. the integer
index of the field to be extracted (default is |
The function get_name()
extracts the symbol names (tickers)
from a vector of character strings. If the input is a vector of
strings, then get_name()
returns a vector of names.
The input string is assumed to be in the format "name.csv", with the
name at the beginning of the string, but get_name()
can also parse
the name from other string formats as well. For example, it extracts the
name "VTI" from the string "VTI.Close", or it extracts the name "XLU" from
the string "XLU2017_09_05.csv" (with sep="_"
).
A vector of character strings containing symbol names.
# Extract symbols "XLU" and"XLP" from file names
rutils::get_name(c("XLU.csv", "XLP.csv"))
# Extract symbols from file names
rutils::get_name("XLU2017_09_05.csv", sep="_")
rutils::get_name("XLU 2017 09 05.csv", sep=" ")
# Extract fields "Open", "High", "Low", "Close" from column names
rutils::get_name(c("VTI.Open", "VTI.High", "VTI.Low", "VTI.Close"), field=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.