diff --git a/R/isfield.R b/R/isfield.R new file mode 100644 index 0000000..ef818a2 --- /dev/null +++ b/R/isfield.R @@ -0,0 +1,9 @@ +#' @title Checks if a list contains a field +#' @description This function tries to replicate the behavior of the `isfield` +#' function in Matlab +#' @param x list +#' @param field name of field +#' @references https://se.mathworks.com/help/matlab/ref/isfield.html +isfield <- function(x, field) { + field %in% names(x) +} \ No newline at end of file diff --git a/man/isfield.Rd b/man/isfield.Rd new file mode 100644 index 0000000..a3ccd17 --- /dev/null +++ b/man/isfield.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/isfield.R +\name{isfield} +\alias{isfield} +\title{Checks if a list contains a field} +\usage{ +isfield(x, field) +} +\arguments{ +\item{x}{list} + +\item{field}{name of field} +} +\description{ +This function tries to replicate the behavior of the `isfield` +function in Matlab +} +\references{ +https://se.mathworks.com/help/matlab/ref/isfield.html +}