ordering non-decreasing functions then adding them in R -


need basic r function:

firstly order non-decreasing sequence 4 different sequences , order 4 sequences one.

im totally green in programing please make simplest way possible.

edit1: puting input data required

a={3,2,1,2} b={6,7,5,8} c={12,11,9,10} d={65,43,76,13} 

i first order each sequence, so

a={1,2,2,3} b={5,6,7,8} c={9,10,11,12} d={13,43,65,76} 

and merge it

abcd={1,2,2,4,5,6,7,8,9,10,11,12,13,43,65,76} 

if want function takes vectors a, b, c, , d , input , outputs sorted version of them, can try:

sortall <- function(a, b, c, d) sort(c(a, b, c, d)) 

and can run like:

a <- c(1,2,2,3) b <- c(5,6,7,8) c <- c(9,10,11,12) d <- c(13,43,65,76) sortall(a, b, c, d) # [1]  1  2  2  3  5  6  7  8  9 10 11 12 13 43 65 76 

if wanted write function combined , sorted number of inputs, try:

sortall <- function(...) sort(unlist(list(...))) sortall(a, b, c, d) # [1]  1  2  2  3  5  6  7  8  9 10 11 12 13 43 65 76 sortall(a) # [1] 1 2 2 3 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -