Learn R Programming

FastUtils (version 0.2.1)

add: Add Two Objects

Description

This function adds two objects. If both objects are numeric vectors, it performs element-wise addition. If one or both objects are strings, it concatenates them. For other objects, it attempts to use the + method defined for the class of the objects.

Usage

add(x, y)

Value

The result of adding the two objects.

Arguments

x

An object.

y

An object.

Examples

Run this code
# Add two numeric vectors
add(c(1, 2, 3), c(4, 5, 6))
# Concatenate two strings
add("hello", "world")
# Add a number and a string (concatenation)
add(1, " world")

Run the code above in your browser using DataLab