Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This project is about analyzing a function definition. More precisely, it is about taking a function s definition and returning a data frame with two

This project is about analyzing a function definition. More precisely, it is about taking a functions definition and returning a data frame with two columns. The first one contains all symbols used in the functions definition, and the second one has either the environments name containing the definition of the symbol or a description of the symbols type, e.g., locally defined, given as argument, etc.
Technically, you must define a function listSymbols(), taking a single argument f and returning a data frame. It is assumed that the function f is a closure (not a builtin, as those are compiled functions and we cannot see their code from the level of pure R language). The following examples present the particular functionalities of the required function.
Example 1
Let us start with a straightforward example. First, the function is defined, and then we list all symbols used in defining the function.
g <- function(){
print("Hello world!")
}
g()
[1] "Hello world!"
When we run the function, it prints the string "Hello world!" to the console. There are two symbols used in the function's definition. One is print, and the other is {. Both symbols are defined in the package base. We can see it using the function listSymbols() as shown in the following snippet.
listSymbols(f = g)
symbol definition
1{ base
2 print base
The output of the function is a data frame containing two columns. The first column shows symbols, while the second column shows an environment where the symbol is defined. Here, both symbols are defined in the base package.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

Buddy Dog Foods management to change its focus?

Answered: 1 week ago