Just getting started with R and would value your input on this question.
What I'm trying to achieve is that:
- X axis has all values for "Timestamp"(from 0 to 9)
- Y axis has all values for "NID"(from 0 to 3)
- There are "dots" at the coordinates of ("Timestamp","NID") where the attribute "Fired" = 1.
The source data has the following format:
dat = structure(list(TimeStamp = c(0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L,
4L), NID = c(0L, 1L, 2L, 3L, 4L, 0L, 1L, 2L, 3L, 4L, 0L, 1L,
2L, 3L, 4L, 0L, 1L, 2L, 3L, 4L, 0L, 1L, 2L, 3L, 4L), NumberSynapsesTotal = c(2L,
2L, 3L, 2L, 4L, 2L, 2L, 3L, 2L, 4L, 2L, 2L, 3L, 2L, 4L, 2L, 2L,
3L, 2L, 4L, 2L, 2L, 3L, 2L, 4L), NumberActiveSynapses = c(1L,
2L, 1L, 2L, 3L, 1L, 2L, 1L, 1L, 0L, 1L, 2L, 1L, 1L, 0L, 1L, 2L,
1L, 1L, 0L, 1L, 0L, 0L, 1L, 0L), Fires = c(1L, 1L, 1L, 1L, 0L,
1L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L,
0L, 1L, 0L, 0L)), row.names = c(NA, 25L), class = "data.frame")
I tried to apply a filter, but it shows a subset of data for those "ID"s, where there is value 1 for the attribute "Fired" (no all values for the axes):
dat %>%
filter(dat$Fires == 1) %>%
ggplot(aes(x = dat$TimeStamp[dat$Fires == 1], y = dat$NID[dat$Fires == 1])) +
geom_point()
Alternatively, I get all existing values for the attributes "Timestamp" and "NID" by using the following code:
plot(dat$TimeStamp, dat$NID,
xlab = "Time", ylab = "Neuron ID")
title(main = "Fire Trace Plot")
so the picture looks in the following way:
Finally, from the comment below I modified the code to:
ggplot(dat, aes(x = TimeStamp, y = NID) , xlab = "Time", ylab ="Neuron
ID") +
geom_blank() +
geom_point(dat = filter(dat) +
#title(main = "Fire Trace Plot")
scale_x_continuous(breaks = F_int_time_breaks(1) )
Is that the case that i should build two charts on one plot? Thank you!