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

Use of statistical tool, #question what is the statistical process to redu...

#question what is the statistical process to reduce hardness of water

CERTIFICATE OF AIRWORTHINESS FOR EXPORT, CERTIFICATE OF AIRWORTHINESS FOR E...

CERTIFICATE OF AIRWORTHINESS FOR EXPORT When aircraft manufacturers go into series production of a new type of aircraft, then obviously they are hopeful of world wide sales. Sim

Find a nash equilibrium, 2 bidders have identical valuations of an object f...

2 bidders have identical valuations of an object for sale. The value of the object is either 0; 50 or 100, with equal probabilities. The object is allocated to one of the bidders i

Statisttics., Explain any two applications of statistics

Explain any two applications of statistics

Variance, Variance The term variance was used to describe the square of...

Variance The term variance was used to describe the square of the standard deviation by R.A.Fisher. The concept of variance is highly important in areas where it is possible to

business forecasting, Explain the characteristics of business forecasting

Explain the characteristics of business forecasting.

Standard deviation for grouped data, Grouped data  For ...

Grouped data  For grouped data, the formula applied is  σ = Where f = frequency of the variable, μ= population mea

Correlation, prove that coefficient of correlation lies between -1 and+1

prove that coefficient of correlation lies between -1 and+1

Standard error, Standard Error The measure of reliability of the estima...

Standard Error The measure of reliability of the estimating equation that we have developed is given by standard error of estimate. The standard error of estimate represented b

Combined standard deviation, How to a calculate the combined standard devia...

How to a calculate the combined standard deviation for five groups (samples)?

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