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

Standard deviation, Standard Deviation The main drawback of the deviati...

Standard Deviation The main drawback of the deviation measures of dispersion, as discussed earlier, is that the positive and negative deviations cancel out each other. Use of t

Statistical process control, Statistical Process Control The variabilit...

Statistical Process Control The variability present in manufacturing process can either be eliminated completely or minimized to the extent possible. Eliminating the variabilit

Assignment 1: Testing Hypotheses for Means, Review the Learning Resources a...

Review the Learning Resources and the media programs related to t tests. For additional support, review the Skill Builder: Research Design and Statistical Design and the Skill Buil

Applications of standard error, Applications of Standard Error   ...

Applications of Standard Error   Standard Error is used to test whether the difference between the sample statistic and the population parameter is significant or is d

Find the inverse laplace transform, Q. Find the inverse Laplace transform o...

Q. Find the inverse Laplace transform of Y (s) = s-4/s 2 + 4s + 13 +3s+5/s 2 - 2s -3. Q. Use the Laplace transform to solve the initial value problem y''+ y = cos(3t), y(0) =

Stata question, i am new to stata and i am trying to figure out how to calc...

i am new to stata and i am trying to figure out how to calculate expected growth of sales tax revenue as well as average growth rate of sales tax revenue in stata. I have a dataset

Find the conditional distribution of turning diameter, 1. Assume the random...

1. Assume the random vector (Trunk Space, Length, Turning diameter) of Japanese car is normally distributed and the unbiased estimators for its mean and variance are the truth. For

Caveat, Caveat We must be careful when interpreting the meaning of asso...

Caveat We must be careful when interpreting the meaning of association. Although two variables may be associated, this association does not imply that variation in the independ

Find the distribution, The Elementary Teachers' Federation of Ontario make ...

The Elementary Teachers' Federation of Ontario make the following claim on their website as of February 13, 2013: For years, the Elementary Teachers' Federation of Ontario (ETFO

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