slightly redundant because it sorts twice, but vectorised,
paste(pmin(a,b), pmax(a,b))
Edit: alternative with ifelse
,
ifelse(a < b, paste(a, b), paste(b, a))
More Related Contents:
- Concatenate row-wise across specific columns of dataframe
- How to paste a string on each element of a vector of strings using apply in R?
- Applying a function to two lists?
- how to apply a function on a data set?
- Is R’s apply family more than syntactic sugar?
- Is the “*apply” family really not vectorized?
- Paste multiple columns together
- Remove columns from dataframe where ALL values are NA
- Faster way to read fixed-width files
- Pass a vector of variables into lm() formula
- R Apply() function on specific dataframe columns
- Adaptive moving average – top performance in R
- subset a column in data frame based on another data frame/list
- Remove/collapse consecutive duplicate values in sequence
- Why is `vapply` safer than `sapply`?
- Is there a R function that applies a function to each pair of columns?
- Why apply() returns a transposed xts matrix?
- Sum every nth points
- Why does as.factor return a character when used inside apply?
- rbind data frames based on a common pattern in data frame name
- Calculate row-wise proportions
- Sorting rows alphabetically
- Concatenate rows of a data frame
- Paste/Collapse in R
- R data.table apply function to rows using columns as arguments
- Row-wise sort then concatenate across specific columns of data frame
- Is there a way to paste together the elements of a vector in R without using a loop?
- Apply function to each column in a data frame observing each columns existing data type
- how to access global/outer scope variable from R apply function?
- apply() not working when checking column class in a data.frame