From 01685bbc94a14fc82d1a29d072c017b26bcfae5d Mon Sep 17 00:00:00 2001
From: Clare <chorscroft@users.noreply.github.com>
Date: Fri, 10 Jul 2020 22:42:14 +0100
Subject: [PATCH] Fixed bug when all distances are 0 and max_dist not suppied

---
 R/create_LDprofile.R | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/R/create_LDprofile.R b/R/create_LDprofile.R
index b4cb5c5..c89fc35 100644
--- a/R/create_LDprofile.R
+++ b/R/create_LDprofile.R
@@ -88,6 +88,10 @@ create_LDprofile<-function(dist,x,bin_size,max_dist=NULL,beta_params=FALSE){
   } else {
     #Set max_dist to the maximum distance in the data if it was not supplied
     max_dist<-max(sapply(dist,function(x){x[length(x)]-x[1]}),na.rm = TRUE)
+    #If max_dist is now zero then set it equal to bin_size
+    if(isTRUE(all.equal(max_dist,0))){
+      max_dist<-bin_size
+    }
   }
   #Adjusts the max_dist value so it is equal to an increment of bin_size if it isn't already
   if(!isTRUE(all.equal(max_dist,assign_bins(bin_size,max_dist)))){
-- 
GitLab