read_npy: Read a '.npy' file

View source: R/read_npy.R

read_npyR Documentation

Read a .npy file

Description

Read a .npy file

Usage

read_npy(file, lazy = FALSE, ...)

Arguments

file

Path to the .npy file

lazy

If TRUE, and file is a path (not a connection), the data payload is memory-mapped rather than read into memory upfront via readBin(). This limits the number of copies in memory when the npy file contains types native to R. Requires a POSIX platform; ignored (with a warning) otherwise. Defaults to FALSE.

...

Ignored. Reserved for future use.

Value

An array containing the data from the .npy file

Examples

# Array of integers. NumPy "<i4" dtype
read_npy(
  system.file("extdata", "test_int32.npy", package = "grumpy")
)

# Array of logicals. NumPy "|b1" dtype
read_npy(
  system.file("extdata", "test_bool.npy", package = "grumpy")
)

# Array of numerics. NumPy "<f8" dtype
read_npy(
  system.file("extdata", "test_float64.npy", package = "grumpy")
)

# Array of strings. NumPy "<U" dtype
read_npy(
  system.file("extdata", "test_str_unicode.npy", package = "grumpy")
)

# "Array" of lists. Numpy structured dtype
read_npy(
  system.file("extdata", "test_structured.npy", package = "grumpy")
)

grumpy documentation built on Nov. 16, 2026, 5:07 p.m.