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

Eco203, Waht is the product of £ x

Waht is the product of £ x

Index Number of formulae, discuss the mathematical test of adequacy of inde...

discuss the mathematical test of adequacy of index number of formulae. prove algebraically that the laspeyre, paasche and fisher price index formulae satisfies this test. What is

Practice-Based Evidence, how to analyzePractice-Based Evidence Back to the ...

how to analyzePractice-Based Evidence Back to the Future

Techniques, Q. 1 a) Describe the important quantitative techniques used in ...

Q. 1 a) Describe the important quantitative techniques used in public system management. (10) b) Do you think the day will come when all decisions are made with the assistance of

The incidence of occupational disease , The incidence of occupational disea...

The incidence of occupational disease in an industry is such that the workers have a 20% chance of suffering from it. What is the probability that out of six workers 4 or more will

Median, The median, as the name suggests, is the middle value of a series a...

The median, as the name suggests, is the middle value of a series arranged in any of the orders of magnitude i.e. ascending or descending order. As distinct from the arithmetic

Time series, merits and demerits of methods to determin trends

merits and demerits of methods to determin trends

Probability, HOW WOULD YOU INTERPRET THIS PROBABILITY:P(a)=1.05

HOW WOULD YOU INTERPRET THIS PROBABILITY:P(a)=1.05

Regression coefficient, Regression Coefficient While analysing regressi...

Regression Coefficient While analysing regression in two related series, we calculate their regression coefficients also. There are two regression coefficients like two regress

Multivariate analysis of variance, Multivariate analysis of variance (MANOV...

Multivariate analysis of variance (MANOVA) is a technique to assess group differences across multiple metric dependent variables simultaneously, based on a set of categorical (non-

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