Learn R Programming

rray (version 0.0.0.9000)

rray_full_like: Create an array like x

Description

  • rray_full_like() creates an array with the same type and size as x, but filled with value.

  • rray_ones_like() is rray_full_like() with value = 1.

  • rray_zeros_like() is rray_full_like() with value = 0.

Usage

rray_full_like(x, value)

rray_ones_like(x)

rray_zeros_like(x)

Arguments

x

A vector, matrix, array or rray.

value

A value coercable to the same inner type as x that will be used to fill the result (If x is an integer matrix, then value will be coerced to an integer).

Details

No dimension names will be on the result.

Examples

Run this code
# NOT RUN {
x <- rray(1:10, c(5, 2))

# Same shape and type as x, but filled with 1
rray_full_like(x, 1L)

# `fill` is coerced to `x` if it can be
rray_full_like(x, FALSE)

# `value = 1`
rray_ones_like(x)

# When logicals are used, it is filled with TRUE
rray_ones_like(c(FALSE, TRUE))

# `value = 0`
rray_zeros_like(x)

# }

Run the code above in your browser using DataLab