I have a frequence table for females and males.
t1 <- table(PainF$task_duration)
t2 <- table(PainM$task_duration)
Females
30 40 45 60 65 70 75 78 80 90 95 100 101 120 144 150 180 185 240
3 3 2 5 1 2 1 1 1 5 1 1 1 3 1 1 1 1 2
Males:
2 10 15 20 30 38 40 45 50 55 60 70 72 73 75 80 90 95 100 105 110 120 130
2 2 1 2 3 1 4 4 3 2 11 1 1 1 1 2 10 1 1 1 1 11 2
150 180 200 240 300 500
2 5 1 3 3 1
This is the table the above number is the duration in minutes for a task and the below is the frequence of people, How can i put this data in a scatter plot, is it possible? I want to compare the data for females and males (the frequence) and duration.
I tried to use ggplot.
ggplot() +
geom_point(data = t1, aes(x = x, y = "column2"), color = "blue", size = 3) +
geom_point(data = t2, aes(x = x, y = "column2"), color = "red", size = 3) +
labs(x = "X", y = "Y", title = "Female and Male task duration") +
theme_minimal()
But i keep getting the following error message.
Error in
fortify(): !datamust be a <data.frame>, or an object coercible byfortify(), or a valid <data.frame>-like object coercible byas.data.frame(). Caused by error in.prevalidate_data_frame_like_object(): !dim(data)must return an of length 2. Runrlang::last_trace()to see where the error occurred.
So my question is can i make a scatterplot based on a frequence table, and if so how can i do that?
> dput(t1)
structure(c(`30` = 3L, `40` = 3L, `45` = 2L, `60` = 5L, `65` = 1L,
`70` = 2L, `75` = 1L, `78` = 1L, `80` = 1L, `90` = 5L, `95` = 1L,
`100` = 1L, `101` = 1L, `120` = 3L, `144` = 1L, `150` = 1L, `180` = 1L,
`185` = 1L, `240` = 2L), dim = 19L, dimnames = list(c("30", "40",
"45", "60", "65", "70", "75", "78", "80", "90", "95", "100",
"101", "120", "144", "150", "180", "185", "240")), class = "table")
> dput(t2)
structure(c(`2` = 2L, `10` = 2L, `15` = 1L, `20` = 2L, `30` = 3L,
`38` = 1L, `40` = 4L, `45` = 4L, `50` = 3L, `55` = 2L, `60` = 11L,
`70` = 1L, `72` = 1L, `73` = 1L, `75` = 1L, `80` = 2L, `90` = 10L,
`95` = 1L, `100` = 1L, `105` = 1L, `110` = 1L, `120` = 11L, `130` = 2L,
`150` = 2L, `180` = 5L, `200` = 1L, `240` = 3L, `300` = 3L, `500` = 1L
), dim = 29L, dimnames = structure(list(c("2", "10", "15", "20",
"30", "38", "40", "45", "50", "55", "60", "70", "72", "73", "75",
"80", "90", "95", "100", "105", "110", "120", "130", "150", "180",
"200", "240", "300", "500")), names = ""), class = "table")

dput(t1)anddput(t2)or a smaller example if these are too large or cannot be shared....geom_point(data = t1 |> as.data.frame(), aes(x = Var1, y = Freq), color = "blue", size = 3) + ...? I wasn't able to load your table for some reason, but that works for me with other data I create usingtable().