![]() ![]() There are no line breaks written into the text. Some of the reasons are long and each takes up its own line. The elements are listed in reverse order from the table because they are assigned to the axis as it increases. Limits=c("Browsed around","Watched large chunks looking for information","Went to specific points to review","Re-watched certain segments based on my homework responses","Watched entire video from start to finish") It was only by using coord_flip() that Reason now appears on the y-axis. We refer to the x-axis here because Reason was originally assigned to be x. The categories can be reordered using the argument limits in the layer scale_x_discrete(). You may have noticed that the order of the categories has changed from the original table. Ggtitle("Strategies for Using Homework Solution and Mini-Lecture Screencasts") + ggplot(data=screencast, aes(x=Reason,y=Percentage,fill=factor(Type))) + ColorĪdding the layers scale_fill_grey() and theme_bw() will change the color scheme to black & white so it is easily printable. The basic structure of the graph has been created, but there is still a lot to do to clean it up. Ggtitle("Strategies for Using Homework Solution and Mini-Lecture Screencasts") Geom_bar(position="dodge",stat="identity") + Now the code and graph look like: ggplot(data=screencast, aes(x=Reason,y=Percentage,fill=factor(Type))) + The layer ggtitle() will title the graph. The layer coord_flip() will flip the x- and y-axes creating a horizontal bar graph, instead of vertical. Next, add the bar graph using the layer geom_bar() with the arguments stat="identity" to use the data as bar heights and position="dodge" so that the two bars don't overlap each other. Ggplot(data=screencast, aes(x=Reason, y=Percentage, fill=factor(Type))) # The first step is specifying the basic form of the graph Note that Type must be used as factor(Type) because R reads the 0,1 entries as integers rather than categories. We will set up the plot as laid out above: Reason will be on the x-axis, Percentage will be on the y-axis, and the data will be split by Type. We will use ggplot() as a base and add on layers to customize our graph. We will use the packages ggplot2 and scales to create the graph. # 9 Watched large chunks looking for information 9 ![]() # 7 Re-watched certain segments based on my homework responses 5 # 6 Watched entire video from start to finish 66 # 4 Watched large chunks looking for information 14 # 2 Re-watched certain segments based on my homework responses 26 # 1 Watched entire video from start to finish 33 Read in and view the new table using screencast <- read.csv("hw1 data2.csv") This is the second Excel table I created: Now when we make the graph, Reason will be on one axis, Percentage will be on the other axis, and each Type will have its own bar. Type has values 0 and 1 representing Homework.solution and Mini.lecture respectively. Using Excel, I created a second representation of the table, a 10x3 matrix with columns Reason, Percentage, and Type and saved it as a. Though the original table is presented one way, we need to change the format slightly for our purposes. Reason will be one axis, but we will want both Homework.solution and Mini.lecture percentages on the other axis. Think about if this table is formatted correctly for a bar graph. This is a 5x3 matrix with column labels Reason, Homework.solution, and Mini.lecture. # 4 Watched large chunks looking for information # 2 Re-watched certain segments based on my homework responses # 1 Watched entire video from start to finish Take a look at the table to make sure it was read properly. csv file into R using screencastOriginal <- read.csv("hw1 data.csv") Set your working directory in R Studio by navigating the menus: Session > Set working directory > Choose directory then choose the folder where you have saved your data. The total number of respondents for each type of screencast will still be included on the final graph, allowing the response counts to be calculated while not cluttering the graph. The table's primary purpose was to make comparisons between strategies for each type of screencast, so the percentages rather than the counts are most important. The table I created includes only the percentages and not response counts. To work with the data in R, first create the table in Excel and save as a. ![]() Table 3 in the article summarizes responses to a survey of strategies for using two types of screencasts: Homework solution screencasts and Mini-lecture screencasts. Journal Of Engineering Education, 101(4), 717-737. Impact of Screencast Technology: Connecting the Perception of Usefulness and the Reality of Performance. GREEN, K., PINDER-GROVER, T., & MILLUNCHICK, J. Tutorial: Turning a Table into a Horizontal Bar Graph using ggplot2 Tutorial: Turning a Table into a Horizontal Bar Graph using ggplot2 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |