From 317d281e70dd7da1fe392ae0aa33b3371bfbc264 Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Tue, 3 Mar 2020 10:50:27 +0100 Subject: [PATCH] Added isfield translation function --- R/isfield.R | 9 +++++++++ man/isfield.Rd | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 R/isfield.R create mode 100644 man/isfield.Rd 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 +}