I am having Three columns in a dataframe. They are as follows -
Column 1 - Row No.
Column 2 - Ma_Value (consist of random numbers 1-100)
Column 3 - Mi_Value (consist of random numbers 1-100)
I plotted a line graph where Column 1 is on the x axis and Column 2 and Column 3 are on y axis.
Can a popup message come in R where the two lines intersect, i.e., Ma_Value and Mi_Value ?
I'm not an expert with popups, but in principle, a popup is triggered when a logical condition is satisfied.
In your particular case, I would propose that the easiest approach to identifying any intersections in the line charts would be if Ma_Value < Mi_Value is TRUE for some pairs and FALSE for others. If all values or FALSE or if all values are TRUE, then the lines never intersect.
nrow <- 10
set.seed(1) # Use for an example on intersecting lines
# set.seed(718) # Use for an example on non-intersecting lines
df <-
data.frame(row = seq_len(nrow),
Ma_Value = sample(1:100, nrow, replace = TRUE),
Mi_Value = sample(1:100, nrow, replace = TRUE))
# If TRUE, the lines intersect
length(unique(df$Ma_Value < df$Mi_Value)) > 1
# plot
library(ggplot2)
library(tidyr)
df %>%
gather(variable, value,
-row) %>%
ggplot(mapping = aes(x = row,
y = value,
colour = variable)) +
geom_point() +
geom_line()