0

my data frame looks like this:

       A           B           C          D          E          F
  0.05105828 -0.08092082 -0.09437686 0.06996891 0.05920997 -0.05926277
  0.04843209 -0.07883489 -0.08424212 0.05259821 0.05397864  0.05728037
 -0.04819604 -0.07768484 -0.08057477 0.05031392 0.05253856  0.05726593
  0.04807908 -0.07471874 -0.07385733 0.04942438 0.05078736  0.05695990

I would like to plot the ecdf row by row in the same plot in order to identify a threshold to use to remove not-informative rows.

Can anyone help me please?

Thank you in advance

NewUsr_stat
  • 2,351
  • 5
  • 28
  • 38
  • Possible duplicate of [How to plot multiple ECDF's on one plot in different colors in R](https://stackoverflow.com/questions/20601642/how-to-plot-multiple-ecdfs-on-one-plot-in-different-colors-in-r) – Clemsang Sep 03 '19 at 09:12
  • Although the question looks similar it is IMO not a dup. – Roman Sep 03 '19 at 09:18

1 Answers1

1

You can try

library(tidyverse)
# some data
set.seed(123)
df <- data.frame(A=rnorm(100)*0.5,
             B=rnorm(100),
             C=rnorm(100)*2,
             D=rnorm(100)*0.9)    
# the plot
df %>% 
  gather(k, v) %>% 
  ggplot(aes(v, color =k)) +
   stat_ecdf(geom = "line") +
   stat_ecdf(geom = "point") 

enter image description here

If you really mean rowwise, you can simply try

df %>% 
  mutate(index = row_number()) %>% 
  gather(k, v, -index) %>% 
  ggplot(aes(v, color = factor(index))) +
  stat_ecdf(geom = "line", show.legend = F) +
  stat_ecdf(geom = "point", show.legend = F) 
Roman
  • 17,008
  • 3
  • 36
  • 49