Question with R - Bioinformatics, Applied Statistics

Assignment Help:
Hi There,

I have a question regarding R, and I am wondering if anyone can help me.

Here is a code that I would like to understand:

squareFunc <- function(f) {
g <- function(x) {
f(x)^2
}

return(g)
}

sin.2 <- squareFunc(sin)

sin.2(1)


In the above code, function sin is nested in suquareFunc, which also has a function g inside.

I am having hard time understanding this code.

For example, if I was asked to write this code, mine would look like:

squareFunc <- function(f) {
g <- f^2
return(g)
}

sin.2 <- squareFunc(sin)

sin.2(1)

and this does not work.


I feel that argument ''f'' in in squareFunc(f) should be passed on to the function ''g'', but what g has is (x).

Obviously the first code works if I type it in R, but I would like to understand how it works.

I may not be asking the right question, but if you can see where I am confused at and can help me to understand it, that would be great.

Thank you very much in advance.

Mayumi

Related Discussions:- Question with R - Bioinformatics

Exam, I need to know if the exam will be guarantee to pull my grade up to a...

I need to know if the exam will be guarantee to pull my grade up to a B or an A. I have a D right now so i need to get someone that is willing to put effort on completing it???

Range, Range Official Exports Target 2000-2001 ...

Range Official Exports Target 2000-2001 Product ($ million) Plantation 500 Agriculture and Alli

Mode, Mode The mode is the value which occurs most frequ...

Mode The mode is the value which occurs most frequently in a set of observations on the point of maximum frequency and around which other items of the set cluste

Calculate the line of best fit, The manager of Pizza Hut provides a deliver...

The manager of Pizza Hut provides a delivery service for customers who telephone in an order. The manager would like to give callers an idea of the time it will take to deliver an

Find out the probability, There are n seats on an airplane and n passengers...

There are n seats on an airplane and n passengers have bought tickets. Unfortunately, the first passenger to enter the plane has lost his ticket and, so he just chooses a seat at r

Job application, .what job can you after offering that course

.what job can you after offering that course

Data analysis, #quesgraphical representation of data

#quesgraphical representation of data

Regression model, Using a random sample of 670 individuals for the populati...

Using a random sample of 670 individuals for the population of people in the workforce in 1976, we want to estimate the impact of education on wages. Let wage denote hourly wage in

Concepts of statistics, what are the importance, uses,optimums and applicat...

what are the importance, uses,optimums and applications of the following in agriculture field experiments; 1.standard deviation 2.standard error 3. coefficient of variation

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd