unpaste(str, sep="/", fnames=NULL, nfields=NULL, first=c(1, 3, 5), width=2)
str
.
If
sep
is not the empty string
""
,
unpaste
uses
sep
to determine field boundaries,
and extracts the contents of each field as a character string.
If
sep
is the empty string,
unpaste
uses
the
first
and
width
argument to determine
the beginning and width of each field,
then uses the
substring
function
to extract the contents of each fixed-format field.
Often, it is convenient to return a character vector instead of a list;
this can be accomplished by wrapping the call
to
unpaste
inside
a call to
unlist
.
# Break a string into its individual characters: unlist(unpaste(str = "seattle", sep = "", first = 1:nchar("seattle"), width = 1)) [1] "s" "e" "a" "t" "t" "l" "e" # Separate the user's path into its components: unpaste(getenv("PATH"), sep=":") # Return the user's path as a character vector: unlist(unpaste(getenv("PATH"), sep=":"))