Just for completeness: The library stringr contains a function for exactly this problem.
library(stringr)
sentence <- "The quick brown fox"
word(sentence,-1)
[1] "fox"
More Related Contents:
- Count number of rows within each group
- Create an empty data.frame
- Add a common Legend for combined ggplots
- Create a group number for each consecutive sequence
- Assign multiple new variables on LHS in a single line
- Where does R store packages?
- Trimming a huge (3.5 GB) csv file to read into R
- regular expressions in base R: ‘perl=TRUE’ vs. the default (PCRE vs. TRE)
- How can I remove empty factors from ggplot2 facets?
- How to add a ggplot2 subtitle with different size and colour?
- Plot data in descending order as appears in data frame [duplicate]
- R knitr: Possible to programmatically modify chunk labels?
- Convert yyyymmdd string to Date class in R
- How to make dodge in geom_bar agree with dodge in geom_errorbar, geom_point
- set only lower bound of a limit for ggplot
- Last Observation Carried Forward In a data frame? [duplicate]
- different size facets proportional of x axis on ggplot 2 r
- There is pmin and pmax each taking na.rm, why no psum?
- Extract file extension from file path
- Add x and y axis to all facet_wrap
- How to change positions of x and y axis in ggplot2
- Add values to a reactive table in shiny
- Error with select function from dplyr
- R Plot Filled Longitude-Latitude Grid Cells on Map
- no visible global function definition for ‘median’
- Duplicate list names in R
- how can I handle vectors without knowing the type in Rcpp
- Adding a counter column for a set of similar rows in R [duplicate]
- R data table: update join
- Importing “csv” file with multiple-character separator to R?