In R programming, ** get0() **and

**function works similar to**

`mget()`

`get()`

function. It is used to search and return the object with the specified name passed to it as argument.#### get0() Function

** get0()** function has the same syntax as

`get()`

function but there is an addition of a new parameter which returns an output if the data object is not found. Clearly, this is making user-generated exception in a way.

Syntax:get0(x, mode, ifnotfound)

Parameters:

x:represents data object to be searched

mode:represents type of data object

ifnotfound:represents the output that has to be returned whenxis not found

**Example:**

`# Define data objects ` `x <- ` `c` `(1, 2, 3) ` `y <- ` `c` `(` `"a"` `, ` `"b"` `, ` `"c"` `) ` ` ` `# Searching using get0() function ` `get0` `(` `"x"` `, ifnotfound = ` `"not found"` `) ` `get0` `(` `"x1"` `, ifnotfound = ` `"not found"` `) ` |

*chevron_right*

*filter_none*

**Output:**

[1] 1 2 3 [1] "not found"

#### mget() function

** mget()** function in R programming works similar to

`get()`

function but, it is able to search for multiple data objects rather than a single object in `get()`

function.

Syntax:mget(x, mode, ifnotfound)

Parameters:

x:represents character vector of object names

mode:represents type of data object

ifnotfound:represents the output that has to be returned when x is not found

**Example:**

`# Defining data objects ` `x <- ` `c` `(1, 2, 3) ` `y <- ` `c` `(` `"a"` `, ` `"b"` `, ` `"c"` `) ` ` ` `# Searching using mget() function ` `mget` `(` `c` `(` `"x"` `, ` `"y"` `, ` `"x1"` `), ifnotfound = ` `"Not Found"` `) ` |

*chevron_right*

*filter_none*

**Output:**

$x [1] 1 2 3 $y [1] "a" "b" "c" $x1 [1] "Not Found"

## Recommended Posts:

- Search and Return an Object with the specified name in R Programming - get() Function
- Check if an Object of the Specified Name is Defined or not in R Programming - exists() Function
- Coercing the Argument to a Name in R Programming - as.name() Function
- Check if the Argument is a Name in R Programming - is.name() Function
- Return True Indices of a Logical Object in R Programming - which() Function
- Find Location and Character Vector of an Object with partial name in R Language - apropos() and find() Function
- Return a Matrix with Lower Triangle as TRUE values in R Programming - lower.tri() Function
- Return a Matrix with Upper Triangle as TRUE values in R Programming - upper.tri() Function
- Return the Index of the First Minimum Value of a Numeric Vector in R Programming - which.min() Function
- Return the Index of the First Maximum Value of a Numeric Vector in R Programming - which.max() Function
- Return a Logical Vector with Missing Values removed in R Programming - complete.cases() Function
- Create a Vector of Colors with specified Hue, Chroma and Luminance in R Programming - hcl() Function
- Create a Vector of Colors with specified Hue, Saturation and Value in R Programming - hsv() Function
- Get Indices of Specified Values of an Array in R Programming - arrayInd() Function
- Extract word from a String at specified position in R Programming - word() Function
- Create Line Curves for Specified Equations in R Programming - curve() Function
- Rounding up to the Specified Number of Significant Digits in R Programming - signif() Function
- Trim a String to a Specified Display Width in R Programming - strtrim() Function
- Generate Factors with specified Levels in R Programming - gl() Function
- Draw a Polygon between specified points in R Programming - polygon() Function

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.