Search code examples
rstatisticstibble

How to save the output results of Sen's Slope


I am using this code to calculate Sen's Slope

x1<-data$Prec_45_BC
Prec45<- sens.slope(x1)

Its output results are as below. How can I save them in the table form and further export them to CSV.

data:  x1
z = -1.7156, n = 430, p-value = 0.08624
alternative hypothesis: true z is not equal to 0
95 percent confidence interval:
 -0.025611763  0.002016025
sample estimates:
Sen's slope 
-0.01234117 

Solution

  • The issue here seems to be that the data first has to be unlisted in order to write it as a CSV. The following example code allows for saving the output of Sen's Slope to a CSV:

    library('trend')
    
    data(maxau)
    out <- sens.slope(maxau[,"s"])
    out <- data.frame(unlist(out))
    
    write.csv(out, "out.csv")
    

    However, I'm not fully sure what was meant by saving it "in the table form".