Here’s one way:
idx <- order(c(seq_along(a), seq_along(b)))
unlist(c(a,b))[idx]
# [1] "a.1" "b.1" "a.2" "b.2" "a.3" "b.3" "b.4"
As @James points out, since you need a list back, you should do:
(c(a,b))[idx]
Related Contents:
- The difference between bracket [ ] and double bracket [[ ]] for accessing the elements of a list or dataframe
- Mean per group in a data.frame [duplicate]
- Replacing NAs with latest non-NA value
- Aggregating by unique identifier and concatenating related values into a string [duplicate]
- Count number of rows per group and add result to original data frame
- Subset rows corresponding to max value by group using data.table
- How to call an object with the character variable of the same name
- Error: unexpected symbol/input/string constant/numeric constant/SPECIAL in my code
- How to convert a data frame column to numeric type?
- Count number of occurences for each unique value
- How to open CSV file in R when R says “no such file or directory”?
- What does .SD stand for in data.table in R
- R: Plotting a 3D surface from x, y, z
- Proper idiom for adding zero count rows in tidyr/dplyr
- Re-ordering factor levels in data frame [duplicate]
- How to omit NA values while pasting numerous column values together?
- Dealing with TRUE, FALSE, NA and NaN
- Is there a more elegant way to convert two-digit years to four-digit years with lubridate?
- Fast pairwise simple linear regression between variables in a data frame
- Sorting rows alphabetically
- ggplot2: Curly braces on an axis?
- Decompress gz file using R
- How to access the last value in a vector?
- Changing font size and direction of axes text in ggplot2
- How to access and edit Rprofile? [closed]
- Assign unique ID based on two columns [duplicate]
- Why and where are \n newline characters getting introduced to c()?
- Equivalent to unix “less” command within R console
- Set margin size when converting from Markdown to PDF with pandoc
- lambda-like functions in R?
- Generate Dynamic R Markdown Blocks
- Is it possible to stop executing of R code inside shiny (without stopping the shiny process)?
- Finding 2 & 3 word Phrases Using R TM Package
- How can I order the months chronologically in ggplot2 short of writing the months out?
- Error in if/while (condition) { : argument is of length zero
- How to delete groups containing less than 3 rows of data in R? [duplicate]
- pass function arguments to both dplyr and ggplot
- Handling dates when we switch to daylight savings time and back
- How to change the first row to be the header in R?
- Convert yyyymmdd string to Date class in R
- data.table merge based on date ranges
- Splitting a string into new rows in R [duplicate]
- Order x axis day values in ggplot2
- How to give subtitles for subplot in plot_ly using R
- How to merge and sum two data frames
- Calculate group mean while excluding current observation using dplyr
- How to read csv file in R where some values contain the percent symbol (%)
- Change values in multiple columns of a dataframe using a lookup table
- List of ggplot2 theme options?
- How to get unsaved script tabs