1
I have a df with two variables. The first is a time counter that reaches 9min at a 1000Hz acquisition rate (so it’s huge 540 thousand lines). The second variable is an electrophysiological measurement in us (micro Siemens). Follow the first 20 lines below:
> dput(head(SC,20))
structure(list(time = c(0, 0.001, 0.002, 0.003, 0.004, 0.005,
0.006, 0.007, 0.008, 0.009, 0.01, 0.011, 0.012, 0.013, 0.014,
0.015, 0.016, 0.017, 0.018, 0.019), Conductance = c(0, 0, 0,
0.01, 0.01, 0.02, 0.03, 0.04, 0.05, 0.07, 0.07, 0.08, 0.09, 0.09,
0.09, 0.09, 0.1, 0.09, 0.09, 0.09)), row.names = c(NA, 20L), class = "data.frame")
I converted the variable "time" to a Posixct and need to plot on a graph. However, I do not want to plot the entire Time variable. Only part of it. I have no skill with Posixct and do not know how to edit the "xlim" of the chart.
require(lubridate)
SC$time <- as_datetime(SC$time)
> head(SC$time)
[1] "1970-01-01 00:00:00 UTC" "1970-01-01 00:00:00 UTC"
[3] "1970-01-01 00:00:00 UTC" "1970-01-01 00:00:00 UTC"
[5] "1970-01-01 00:00:00 UTC" "1970-01-01 00:00:00 UTC"
> tail(SC$time,10)
[1] "1970-01-01 00:09:13 UTC" "1970-01-01 00:09:13 UTC"
[3] "1970-01-01 00:09:13 UTC" "1970-01-01 00:09:13 UTC"
[5] "1970-01-01 00:09:13 UTC" "1970-01-01 00:09:13 UTC"
[7] "1970-01-01 00:09:13 UTC" "1970-01-01 00:09:13 UTC"
[9] "1970-01-01 00:09:13 UTC" "1970-01-01 00:09:13 UTC"
I used the following code but it takes all the information, including the x-axis format does not look good pq includes HORA (which is not relevant):
pl <- ggplot(SC, aes(x = time, Conductance)) + geom_line()
How to adjust the x-axis for any desired time unit (window)? For example: only from 2.5 minutes to 6.5 minutes (5min window therefore).
Share your data using the result of
dput(head(SC, 20))
that it will make life much easier for anyone who tries to help you.– Marcus Nunes
Can you post with the values after Posixct? And the expected result is only with the minutes in xlim?
– Jorge Mendes