From ?strsplit
, a function that’ll reverse every string in a vector of strings:
## a useful function: rev() for strings
strReverse <- function(x)
sapply(lapply(strsplit(x, NULL), rev), paste, collapse="")
strReverse(c("abc", "Statistics"))
# [1] "cba" "scitsitatS"
More Related Contents:
- Combine two data frames by rows (rbind) when they have different sets of columns
- How to combine multiple conditions to subset a data-frame using “OR”?
- How to merge 2 vectors alternating indexes?
- How to put labels over geom_bar in R with ggplot2
- Wrap long axis labels via labeller=label_wrap in ggplot2
- Access variable value where the name of variable is stored in a string
- Converting decimal to binary in R?
- R Shiny – add tabPanel to tabsetPanel dynamically (with the use of renderUI)
- How to generate a number of most distinctive colors in R?
- Keeping trailing zeros
- Bar plot with log scales
- Rstudio rmarkdown: both portrait and landscape layout in a single PDF
- Passing command line arguments to R CMD BATCH
- Displaying a greater than or equal sign
- How to change order of boxplots when using ggplot2?
- listing contents of an R data file without loading
- How do you determine the namespace of a function?
- R: Plotting a 3D surface from x, y, z
- How to fill with different colors between two lines? (originally: fill geom_polygon with different colors above and below y = 0 (or any other value)?)
- How to extract certain columns from a list of data frames
- How to find out which package version is loaded in R?
- ggplot geom_point() with colors based on specific, discrete values
- For the same code, labels (q1, median) appear on one computer but don’t appear on another computer
- Moving color key in R heatmap.2 (function of gplots package)
- GGplot custom scale transformation with custom ticks
- Is there a way to paste together the elements of a vector in R without using a loop?
- ddply for sum by group in R
- Merge dataframes, different lengths
- Dealing with spaces and “weird” characters in column names with dplyr::rename()
- Filtering rows in R unexpectedly removes NAs when using subset or dplyr::filter