Note that there are some explanatory texts on larger screens.

plurals
  1. POGantt style time line plot (in base R)
    primarykey
    data
    text
    <p>I have a dataframe that looks like this:</p> <pre><code> person n start end 1 sam 6 0 6 2 greg 5 6 11 3 teacher 4 11 15 4 sam 4 15 19 5 greg 5 19 24 6 sally 5 24 29 7 greg 4 29 33 8 sam 3 33 36 9 sally 5 36 41 10 researcher 6 41 47 11 greg 6 47 53 </code></pre> <p>Where start and end are times or durations (sam spoke from 0 to 6; greg from 6 to 11 etc.). n is how long (in this case # of words) the person spoke. I want to plot this as a time line in base R (I eventually may ask a similar question using ggplot2 but this answer is specific to base R [when I say base I mean the packages that come with a standard install]). </p> <p>The y axis will be by person and the x axis will be time. Hopefully the final product looks something like this for the data above:</p> <p><img src="https://i.stack.imgur.com/sLkRt.jpg" alt="Timeline_Graph"></p> <p>I would like to use base R to make this. I'm not sure how to approach this. My thoughts are to use a dot plot and plot a dotplot but leave out the dots. Then go over this with square end segments. I'm not sure about how this will work since the segments need numeric x and y points to make the segments and the y axis is categorical. Another thought is to convert the factors to numeric (assign each factor a number) and plot as a blank scatterplot and then go over with square end line segments. This could be a powerful tool in my field looking at speech patterns. </p> <p>I thank you in advance for your help.</p> <p><em>PS the argument for square ended line segments is</em> <code>segments(... , lend=2)</code> <em>to save time looking this information up for those not familiar with all the segment arguments.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload