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]
More Related Contents:
- How to get summary statistics by group
- pivot_wider issue “Values in `values_from` are not uniquely identified; output will contain list-cols”
- Scheduling R Script
- Create stacked barplot where each stack is scaled to sum to 100%
- Setting individual axis limits with facet_wrap and scales = “free” in ggplot2
- How do you order the fill-colours within ggplot2 geom_bar
- Getting LaTeX into R Plots
- How to wait for a keypress in R?
- Simplest way to get rbind to ignore column names
- Growing a data.frame in a memory-efficient manner
- Difference between passing options in aes() and outside of it in ggplot2
- How to make gradient color filled timeseries plot in R
- Setting document title in Rmarkdown from parameters
- R and System calls
- passing several arguments to FUN of lapply (and others *apply)
- Convert data frame with date column to timeseries
- ggplot2 multiple scales/legends per aesthetic, revisited [duplicate]
- Tidyr how to spread into count of occurrence [duplicate]
- What is the most useful R trick? [closed]
- What methods can we use to reshape VERY large data sets?
- Using lapply to apply a function over list of data frames and saving output to files with different names
- Recognize PDF table using R
- Output a vector in R in the same format used for inputting it into R
- Working with neuralnet in R for the first time: get “requires numeric/complex matrix/vector arguments”
- Row-wise sum of values grouped by columns with same name
- Create binary column (0/1) based on condition in another column
- Check if string contains ONLY NUMBERS or ONLY CHARACTERS (R)
- Empty factors in “by” data.table
- How to extract substring between patterns “_” and “.” in R [duplicate]
- Count number of non-NA values by group