The task here is to come up with descriptive measures for the data in Table 1.

This page assumes that you have read through earlier pages and that you have mastered the steps that we use to set up our work. To that end we will assume that we have

- inserted our USB drive,
- created a directory called
on that drive`worksheet033`

- have copied
from our root folder into our new folder,`model.R`

- have renamed that new copy of the file to the name
, and`ws33.R`

- have double clicked on that file to open
**RStudio**.

Much of the discussion that would be given here has been included in the comments in our

`ws33.R`

The console view of those commands:

The we add the commands to generate and display the midpoints.

In Figure 5 we can see all of those midpoint values.

Then we enter the values of all of the frequencies.

In Figure 7 we can visually verify that we have them correctly entered.

Because the problem was kind enough to give us a way to check that we have the correct values, we might as well compute the sum of the products of the frequencies times the midpoints. Figure 8 shows the required command.

Running that command gives us the value in Figure 9. We see that it matches and we can move on with some confidence.

Now we want to use the mipoints and the frequencies to generate data that will approximate the data represented in

It turns out that we need

A quick look at the

`mid_pnts`

`mid_pnts`

Just for the fun of it, Figure 13 shows the command to actually compute the sum of the the

`freqs`

And, when we rn that command we see in Figure 14 that there are indeed

We can now dive into finding the various descriptive measures. Remember that we have an new

`worksheet033`

Figure 16 shows the various values.

As we have seen before the

`summary`

This gives rise, in Figure 18, to a restatement of the results of the

`summary`

The we create the command for a quick and dirty bar plot.

The

Instead, the plot shows up in its own pane, displayed in Figure 21.

That is a pretty ugly plot, but it does get across the graph of the distribution of values in our data.

Even though we started with a frequency table,

`make_freq_table`

We get the

The

`View(ft)`

`ws33.R`

That will change the color of the file name, as we see in Figure 25.

Finally, in the

`q()`

`y`

Once we press ENTER after that the

Here is a listing of the complete contents of the

`ws33.R`

# Worksheet 3.3 asks that we find descriptive measures # for the data given as the frequency of grouped data. # The frequencies are given but we need to find the midpoint # of each of the intervals. Fortunately, in this example, # all of the intervals have equal width. We will enter # all of the low values then find the midpoints. low_vals <- seq( 175,378,29)# start, stop, step size low_vals # The the midpoints are just 29/2 higher than the low values mid_pnts <- low_vals + (29/2) mid_pnts # now put the frequencies into a variable freqs <- c(33, 15, 29, 25, 21, 27, 32, 27 ) freqs # Of course we can visually inspect the values so far # but the problem gave us a little help when it told # us that "the sum of the frequencies times the # midpoint of the respective span is 61297.50" # We can find that value sum(freqs*mid_pnts) # Now that we feel that we have the values correctly # established we can use the frequencies and midpoints # to create our "raw" data. data_raw <- rep( mid_pnts, freqs) data_raw # this looks good but, just as a quick check, we will # find the sum of all the frequencies. sum(freqs) # Now we can just find all of the descriptive values # using the raw data summary( data_raw ) mean(data_raw) sd( data_raw ) source("../pop_sd.R") source("../make_freq_table.R") pop_sd( data_raw ) # just as a small aside, we will encourage R to show more # digits and then do the summary command again options(digits=9) summary( data_raw ) # The appropriate graph for this is the bar plot barplot( table(data_raw ) ) # Note that the height of the bars is just the frequency # values. Then we can go on to make a full frequency # table ft <- make_freq_table( data_raw ) ft View(ft)

©Roger M. Palay Saline, MI 48176 January, 2017