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

Problem set for logistic regression, (1) What values can the response varia...

(1) What values can the response variable Y take in logistic regression, and hence what statistical distribution does Y follow? The response variable can take the value of either

Regression and anova, The first step in this case is to ensure that you ar...

The first step in this case is to ensure that you are adequately clear on the General Linear Model and its relationship to both ANOVA and regression. The distinction is approxim

Distrbution., The score distribution shown in the table is for all students...

The score distribution shown in the table is for all students who took a yearly AP statistical exam. An AP statistics teacher had 59 students preparing to take the AP exam. Though

Weight distribution, What does the confidence level of a confidence interva...

What does the confidence level of a confidence interval tell you? Suppose that a population has mean, µ, and standard deviation, σ.  What does the central limit theorem tell us

Analysis of variance for the data, Analysis of Variance for the data: ...

Analysis of Variance for the data: Draw a random sample of size 25 from the following data : (a) With Replacement and   (b) Without Replacement and obtain Mean and Varia

Trying to find test statistic and P value, Ask question #Minimum The data i...

Ask question #Minimum The data in the accompanying table give the weights? (in g) of randomly selected quarters that were minted after 1964. The quarters are supposed to have a med

Population census, what are the challenges affecting population census in d...

what are the challenges affecting population census in developing countries

Critique 2, prepare a critical analysis of a quantitative study focusing on...

prepare a critical analysis of a quantitative study focusing on protection of human participants data collection data management and analysis problem statement and interpretation o

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