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

calculate the test statistics, A manufacturer has received complaints that...

A manufacturer has received complaints that aging production equipment is forcing workers to work overtime in order to meet production quotas. Historically, the average hours worke

Hortons initial infiltration capacity, (a) The Horton's initial infiltratio...

(a) The Horton's initial infiltration capacity for a catchment is 204 mm/h and the constant infiltration value at saturation is 60 mm/h. For a rainfall in excess of 204 mm/h mainta

Bernoulli trial, Statistician is searching the \home ground" effect and is ...

Statistician is searching the \home ground" effect and is studying 20 football games, of which 14 were won by the home team and 6 by the visitors. Therefore the game is a Bernoulli

Define the partial market equilibrium model, Q. The following system of equ...

Q. The following system of equations illustrates the algebraic form of a partial (individual) market equilibrium model, which is a model of price (P) and quantity (Q) determination

Determine the lower and upper fences, To study the physical fitness of a sa...

To study the physical fitness of a sample of 28 people, the data below was collected representing the  number of sit-ups that a person could do in one minute.      10    12

Large-sample and small-sample simulations, Show that when h = h* for the h...

Show that when h = h* for the histogram, the contribution to AMISE of the IV and ISB terms is asymptotically in the ratio 2:1. Compare the sensitivity of the AMISE(ch) in Equa

Quota sampling, Quota sampling Under this method enumerators shall sele...

Quota sampling Under this method enumerators shall select the respondents in place of those not available, as per the quota fixed according  to guide lines   provided to them.

ANOVA, Your company operates a machine shop, and, having heard you had expe...

Your company operates a machine shop, and, having heard you had experience in statistics and design of experiments, consulted you for your opinion on an experiment they want to run

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