Link to HTML file

Purpose

This document examines demonstrates how to plot participant demographics from a study examining adult listener perceptions of child language utterances.

The variables contained are:

The data set

Here are the data:

##    ID ST Gndr Age Hspnc       Rc           VSI HI SPI Eng.L1
## 1   1 IL    F  22     N    White  Yes-Contacts No  No    Yes
## 2   2 AR    F  21     N    White    Yes-Normal No  No    Yes
## 3   3 KS    F  20     N    White    Yes-Normal No  No    Yes
## 4   4 KS    F  21     Y Hispanic    Yes-Normal No  No    Yes
## 5   5 MO    F  21     Y Hispanic    Yes-Normal No  No    Yes
## 6   6 KS    F  20     N    White    Yes-Normal No  No    Yes
## 7   7 FL    M  25     N    White    Yes-Normal No  No    Yes
## 8   8 KS    F  22     N    White    Yes-Normal No  No    Yes
## 9   9 KS    F  21     N    Asian    Yes-Normal No  No    Yes
## 10 10 KS    F  21     N    White   Yes-glasses No  No    Yes
## 11 11 KS    F  22     N    White    Yes-normal No  No    Yes
## 12 12 KS    F  22     N    White   Yes-glasses No  No    Yes
## 13 13 NE    M  34     N    White    Yes-Normal No  No    Yes
## 14 14 KS    F  23     N    White Yes-corrected No  No    Yes
## 15 15 IL    F  25     N    White    Yes-Normal No  No    Yes
## 16 16 KS    M  26     N    White   Yes-glasses No  No    Yes
## 17 17 CO    F  25     N    White   Yes-glasses No  No    Yes
## 18 18 KS    F  28     Y Hispanic   Yes-glasses No  No    Yes
## 19 19 MO    F  27     N    White Yes-corrected No  No    Yes
## 20 20 KS    F  20     N    White   Yes-glasses No  No    Yes
## 21 21 KS    F  20     N    White   Yes-glasses No  No    Yes
## 22 22 IL    F  23     N    White    Yes-Normal No  No    Yes
## 23 23 MD    M  35     N    White    Yes-Normal No  No    Yes
## 24 24 IL    F  21     N    White   Yes-glasses No  No    Yes
## 25 25 OR    M  32     N    White   Yes-glasses No  No    Yes
## 26 26 ID    F  63     N    White   Yes-glasses No  No    Yes
## 27 27 ID    M  66     N    White   Yes-glasses No  No    Yes
## 28 28 OR    F  43     N    White   Yes-glasses No  No    Yes
## 29 29 KS    F  42     N    White    Yes-Normal No  No    Yes
## 30 30 CA    F  20     N    White    Yes-Normal No  No    Yes
##                                        L2s
## 1                                  Spanish
## 2                                     None
## 3                                     None
## 4                                  Spanish
## 5                                  Spanish
## 6                                     None
## 7                          Spanish, Arabic
## 8                                  Spanish
## 9                      Spanish, Vietnamese
## 10                                 Spanish
## 11                                 Spanish
## 12                                    None
## 13                                    None
## 14                                    None
## 15                                    None
## 16          Spanish, Wolof, French, Ibibio
## 17                         Spanish, French
## 18                                 Spanish
## 19                                 Spanish
## 20                                     ASL
## 21                                    None
## 22                                    None
## 23                                Mandarin
## 24                                    None
## 25 Spanish, Afrikaans, Cantonese, Mandarin
## 26                                    None
## 27                                Mandarin
## 28                                    None
## 29                                    None
## 30                                 Spanish

Let’s create a table showing the number of study participants by state by choosing the “ST” column from the above data frame:

  • First, name your table “tab1”
  • Next, use the “table” function to choose states (ST) from the data frame
  • Finally, display tab1
tab1 <- table(df$ST)
tab1
## 
## AR CA CO FL ID IL KS MD MO NE OR 
##  1  1  1  1  2  4 14  1  2  1  2

Now let’s sort the table by the number of participants in each state (most frequent to least frequent):

  • Create a new, frequency based table (tab2) using the following code:
tab2 <- tab1[order(tab1, decreasing = TRUE)]
tab2
## 
## KS IL ID MO OR AR CA CO FL MD NE 
## 14  4  2  2  2  1  1  1  1  1  1

And finally, let’s create a bar-graph showing plotting the number of participants by state:

barplot(tab2)

We can also view these data by location: participants by state

Data plotted using the following code:

(plot_usmap(data = state_data[,2:3], regions=“states”, values=“ct”) + theme(legend.position = “right”)