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

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

what are the challenges affecting population census in developing countries

Calculate the maximum weight of the engine, Determine the maximum weight in...

Determine the maximum weight in kN to one decimal point (1 DP) of the engine that can be supported without exceeding the tension given in  Parameter 1 (P1) in chain AB or 1.1 x P1

Regression analysis , The data used is from a statistical software Minitab;...

The data used is from a statistical software Minitab; London.MPJ is the file that consists of 1519 households drawn from 1980 - 1982 British Family Expenditure Surveys. Data that i

Bimodal distribution, There may be two values which occur with the same max...

There may be two values which occur with the same maximum frequency. The distribution is then called bimodal. In a bimodal distribution, the value of mode cannot be determined with

Calculation for discrete series or ungrouped data , Calculation for Discre...

Calculation for Discrete Series or Ungrouped Data The formula for computing mean is = where,          f  = fr

Chi square test for more than two rows, Using Chi Square Test when more tha...

Using Chi Square Test when more than two Rows are Present   To understand this, let us consider the contingency table shown below. It gives us the information about the stage

Index number , how to write result in the end of price index number problem...

how to write result in the end of price index number problem

Types of averages, The following are the various types of common averages u...

The following are the various types of common averages used in statistical analysis given in the form of a chart. Figure 1

Business reporting and analysis, You are a business analyst working for a c...

You are a business analyst working for a company called Combined Computers Pty Ltd. You have been asked to prepare a business report with statistics in it for the managing director

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