2

I have two unequal vectors in length. For example, I want to add all values from TT to all values from FF.

TT <- c(1:10)
FF <- c(0, 60, 120, 180)

I would expect to have the below result

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190

I would appreciate if you could give me some advice.

Thanks in advance

1 Answer 1

2

We can use outer

c(outer(TT, FF, FUN = `+`))

or with sapply

c(sapply(TT, `+`, FF))
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much @akrun. sapply fits my aim.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.