Using the aggregate function, as in Example 3.5.1, obtain the frequency instead of sum. Also, extend the

Question:

Using the aggregate function, as in Example 3.5.1, obtain the frequency instead of sum. Also, extend the list variables in the example to include both GPP and Grade, and hence obtain the sum of Sat for possible combinations of these two variables.


Data from in Example 3.5.1

We have the sat.csv fie which contains data on Student ID Number, Grade, Pass indicator, Sat score, and GPP grade. Now, we wish to obtain the sum of the Sat scores by the GPP grade. The aggregate function helps us to achieve the result.

Here we have used the by option to specify the groups, and sum is the FUN option. Thus, we have obtained the group sum using the aggregate function.
Consider a situation where you know what the name of the variables should be. However, for some technical reason you cannot declare them before they are actually assigned some value.
The question is then how can we do such assignments in the flow of a program. As an artificial example, assume that you feed to R the current top ten Sensex companies of the day. Sensex refers to a number indicative of the relative prices of shares on the Mumbai Stock Exchange.

Now, you would like to create objects whose name is the company name and whose value is its Sensex closing value. We will use the assign function towards this end.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

A Course In Statistics With R

ISBN: 9781119152729

1st Edition

Authors: Prabhanjan N. Tattar, Suresh Ramaiah, B. G. Manjunath

Question Posted: