I need to plot ECDF's of all columns of the dataframe in one single plot and get an x_limit on the axis too.
The function that I wrote:
library(lattice)
library(latticeExtra)
  ecdf_plot <-  function(data){
  
     # Drop columns with only NA's
     data <- data[, colSums(is.na(data)) != nrow(data)]
     data$P_key <- NULL
  
     ecdfplot(~ S12, data=data, auto.key=list(space='right'))
  }
Problem: The ECDF in the above function only plots for the column S12 but I need this for all columns in the dataframe. I know i can do S12 + S13 + ... but the source data changes and we don't exactly know how many and which columns will the dataframe get. Is there a better way out of this? Also, is it possible to get the x_limit for the combined plot to be just one range like xlim(0,100)?
                        
I think this task would be easier using ggplot. It would be very easy to set the limits as required, customise the appearance, etc.
The function would look like this:
Now let's test it on a random data frame: