Using substring
is the best approach:
substring(x, seq(1, nchar(x), 2), seq(2, nchar(x), 2))
But here’s a solution with plyr:
library("plyr")
laply(seq(1, nchar(x), 2), function(i) substr(x, i, i+1))
More Related Contents:
- Split delimited strings in a column and insert as new rows [duplicate]
- How to use the strsplit function with a period
- Split a string by any number of spaces
- Splitting a string into new rows in R [duplicate]
- Find all unique values in column separated by comma
- error in strsplit when trying to separate by a comma
- How to convert string rule to an expression which has a range in R [closed]
- Using ggplot2, can I insert a break in the axis?
- Installing older version of R package
- How to subset matrix to one column, maintain matrix data type, maintain row/column names?
- Filter multiple values on a string column in dplyr
- Fixing the order of facets in ggplot
- Multiple plots in for loop ignoring par
- How do I position two legends independently in ggplot
- Replace all particular values in a data frame
- How to source() .R file saved using UTF-8 encoding?
- plotting pie graphs on map in ggplot
- What is the difference between = and ==?
- How to delete rows where all the columns are zero
- using parallel’s parLapply: unable to access variables within parallel code
- Transposing a dataframe maintaining the first column as heading
- Replace a value NA with the value from another column in R
- Clarification of L in R
- Convert integer as “20160119” to different columns of “day” “year” “month”
- What does the R function `poly` really do?
- Confused by …()?
- Identifying where value changes in R data.frame column
- Double clustered standard errors for panel data
- Shiny – observe() triggered by dynamicaly generated inputs
- Create a Vector of All Days Between Two Dates