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

Write out the estimator of the linear combination, Now, let's look at a dif...

Now, let's look at a different linear combination. Suppose we are interested n comparing the average mean log income for no college education ( 16). 1. Write out the linear com

Time series analysis., how is a free hand graph secular trend method plotte...

how is a free hand graph secular trend method plotted

Convenience sampling, Convenience Sampling It means a convenient sample...

Convenience Sampling It means a convenient sample is obtained by selecting convents units from the universe. Convenient sample is also known as chunk. It   means a fraction of

Chi-square analysis, Chi-square analysis can be used with both Goodness-of-...

Chi-square analysis can be used with both Goodness-of-Fit Tests and with Tests for Independence. There are specific instances when each test should be used based on the information

Problem on standard deviation, Your organization purchases bottles of ...

Your organization purchases bottles of a popular commercial solvent for resale.  Each bottle is labeled as containing 32 fluid ounces of the solvent.  Your cont

Logistic regression model, A marketing research firm was engaged by an auto...

A marketing research firm was engaged by an automobile manufacturer to conduct a pilot study to examine the feasibility of using logistic regression for ascertaining the likelihood

Find the optimal order quantity, The Maju Supermarket stocks Munchies Cerea...

The Maju Supermarket stocks Munchies Cereal. Demand for Munchies is 4,000 boxes per year and the super market is open throughout the year. Each box costs $4 and it costs the store

..National Account- Descriptive Statistics, A country''s national accounts ...

A country''s national accounts are assumed to look as follows: GDP 1180 VAT and taxes 140 Commodity subsidies 60 Raw material and consumables 530 1. Calculate GVA 2. Calculate t

X-bar charts, First we look at these charts assuming that we know both the ...

First we look at these charts assuming that we know both the mean and the standard deviation of the process, that is  μ and  σ . These values represent the acceptable values (bench

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