0

I have some data like:

data <- structure(list(Name = c("Luke", "Luke", "Luke", "Luke", "Luke", 
                                 "Luke", "Luke", "Luke", "Luke", "Luke", "Luke", "Luke", "Luke", 
                                 "Luke", "Luke", "Luke", "Leia", "Leia", "Leia", "Leia", "Leia", 
                                 "Leia", "Leia", "Leia", "Leia", "Leia", "Leia", "Leia", "Leia", 
                                 "Leia", "Leia", "Leia", "Leia", "Leia", "Leia", "Leia", "Leia", 
                                 "Leia"), AOI = c("", "A", "A", "B", "A", "", "", "B", "B", "B", 
                                                   "B", "", "", "A", "C", "C", "C", "", "", "B", "", "B", "A", "A", 
                                                   "A", "", "", "B", "", "B", "C", "C", "C", "", "", "X", "Y", "Z"
                                 ), Time_Start = c(0, 3, 5, 10, 12, 14, 15, 20, 22, 25, 38, 40, 53, 
                                              58, 60, 65, 0, 5, 10, 23, 15, 20, 24, 30, 35, 37, 40, 42, 46, 
                                              48, 52, 56, 59, 60, 70, 75, 89, 95), Time_End = c(3, 5, 10, 12, 14, 
                                                                                           15, 20, 22, 25, 38, 40, 53, 58, 60, 65, 65, 5, 10, 23, 15, 20, 
                                                                                           24, 30, 35, 37, 40, 42, 46, 48, 52, 56, 59, 60, 70, 75, 89, 95, 
                                                                                           100), Time_Total = c(65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 
                                                                                                           65, 65, 65, 65, 100, 100, 100, 100, 100, 100, 100, 100, 100, 
                                                                                                           100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100
                                                                                           )), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, 
                                                                                                                                                       -38L))

In column AOI there can be many different entrys, but I know which one will appear. In this case Luke only has A, B and C; Leia got A,B,C,Y and Z. Other persons may have B,C and Y.

I wanted to create something like a sequence chart: on the y-axis I have the name and on the x-axis I get the time spend in each part in a different colour. If the part column is empty it should also be displayed in a different colour.

I already found the AOIanalyseR package, which would be exactly what I'm looking for, but I get an error:

Error: Must request at least one colour from a hue palette

My data looks exactly like the sample data.

The code here would be:

AOIanalyseR::createAOISequenceChart(
  data2,
  ggplot_object = ggplot2::labs(title = "Title", x = "x-axis", y = "y-axis")
)

Since I'm pretty new to R I don't really have an idea where to start finding a solution to this problem.

Thanks in advance for any help!

Edit: Seems like the sample data from AOIanalyseR package is a little bit different. Sample data:

structure(list(Name = c("subject1", "subject1", "subject1", "subject1", 
"subject1", "subject1", "subject1", "subject1", "subject1", "subject1", 
"subject1", "subject2", "subject2", "subject2", "subject2", "subject2", 
"subject2", "subject2", "subject2", "subject2"), AOI = structure(c(4L, 
1L, 2L, 3L, 2L, 3L, 2L, 3L, 4L, 2L, 1L, 1L, 2L, 1L, 3L, 4L, 2L, 
1L, 2L, 3L), .Label = c("", "pic", "text", "title"), class = "factor"), 
    Time_Start = c(0, 2, 3, 8, 10, 12, 16, 22, 24, 26, 28, 0, 
    1, 7, 9, 12, 17, 23, 24, 26), Time_End = c(2, 3, 8, 10, 12, 
    16, 22, 24, 26, 28, 29, 1, 7, 9, 12, 17, 23, 24, 26, 29), 
    Time_Total = c(29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 
    29, 29, 29, 29, 29, 29, 29, 29, 29)), row.names = c("1", 
"110", "111", "112", "113", "114", "115", "116", "117", "118", 
"119", "11", "1101", "1111", "1121", "1131", "1141", "1151", 
"1161", "1171"), class = "data.frame")

But I don't really get what the difference here is and what the actual influence of the different row numbering is since I don't see it referenced somewhere.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Mike Jun 22 '22 at 18:37
  • Please add data as code rather than a screenshot (for example, by pasting the output of `dput(head(data))` into your question), add the code you're using, and your intended output. – Andrea M Jun 22 '22 at 18:40

0 Answers0