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

Diversity of data for the age, The box plot displays the diversity of data ...

The box plot displays the diversity of data for the age; the data ranges from 19 being the minimum value and 60 being the maximum value. The box plot is positively skewed at 0.57 a

Cluster analysis, Cluster Analysis could be also represented more formally ...

Cluster Analysis could be also represented more formally as optimization procedure, which tries to minimize the Residual Sum of Squares objective function: where μ(ωk) - is a centr

Postneonatal mortality rate, Mid year population 440000 Late fatal death...

Mid year population 440000 Late fatal death          29 No. of live birth           5200 No. of infant death      423 No. of maternal death 89 No. of infant deaths i

Confidence interval, a) List down several measures of central tendency and ...

a) List down several measures of central tendency and define the difference among them? b) What do you mean by confidence interval, and why it is useful? What is a confidence lev

Mean and median, The amounts of money won by the top ten finishers in a fam...

The amounts of money won by the top ten finishers in a famous car race are listed below. $1,172,246    $163,659    $440,584    $350,634     $290,596 $186,731    $145,809     $143,2

Compute a correlation coefficient, A researcher was interested lowering the...

A researcher was interested lowering the high school dropout level in his county. He measured the reading level of students entering middle school (based on a standard test) and th

Characteristics of index number, Characteristics of Index Number  On th...

Characteristics of Index Number  On the analysis of various definitions of index number the following may be its characteristics: 1.      Expressed in Number : Index number

Determine the probability, For a distribution of scores with = 82 and stand...

For a distribution of scores with = 82 and standard deviation = 2.5, find the following: (Don't forget to sketch the normal curve to help you visualize what you are trying to fi

Evaluation tracking system, BCBSRI was able to reduce MSD related Workers C...

BCBSRI was able to reduce MSD related Workers Compensation cases with lost workdays by implementing a New Ergonomic Program in March 2000 and increasing workstation evaluations. Ex

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