Question with R - Bioinformatics, Applied Statistics

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) {


sin.2 <- squareFunc(sin)


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

sin.2 <- squareFunc(sin)


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.

Posted Date: 1/20/2013 8:46:28 PM | Location : Canada

Related Discussions:- Question with R - Bioinformatics, Assignment Help, Ask Question on Question with R - Bioinformatics, Get Answer, Expert's Help, Question with R - Bioinformatics Discussions

Write discussion on Question with R - Bioinformatics
Your posts are moderated
Related Questions
prove standard deviation of natural natural numbers

solve problems

Zinc is a trace element and it is important in wound healing, building up the immune system and DNA synthesis. The data in Table 1 represents the zinc intake (in milligrams) for a

In a three-cornered paint ball duel, A, B, and C successively take shots at each other until only one of them remains paint free. Once hit, a player is out of the game and gets no

Cluster Sampling This method is also known as multi stage sampling .Under this method random selection is made of the ultimate or final units from a given stratum. The sampling

Agency revenues. An economic consultant was retained by a large employment agency in a metropolitan area to develop a regression model for predicting monthly agency revenues ( y ).

Given a certain population there are various ways in which a sample may be drawn from it. The chart below illustrates this point: Figure 1 In  Judgem

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