Skip to content

Commit

Permalink
update gen.comm.mat
Browse files Browse the repository at this point in the history
Modified the code such that coord separator used only once at the start
  • Loading branch information
sameerpadhye committed Sep 24, 2024
1 parent 3fecf06 commit bdba8a1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions R/helper.gen.comm.mat.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,19 @@ gen.comm.mat<-function(bold.df,
view.grids=FALSE)
{

bold_df = convert_coord_2_lat_lon(bold.df)

# Check if data is a data frame object

if(is.data.frame(bold.df)==FALSE)
if(is.data.frame(bold_df)==FALSE)

{
stop("Input is not a data frame")
}

# Check whether the data frame is empty

if(nrow(bold.df)==0)
if(nrow(bold_df)==0)

{
stop("Dataframe is empty")
Expand All @@ -81,7 +82,7 @@ gen.comm.mat<-function(bold.df,
{
# The following columns have to be present in the input data frame in order to get the results

if(any((c("bin_uri",taxon.rank,site.cat)%in% names(bold.df)))==FALSE)
if(any((c("bin_uri",taxon.rank,site.cat)%in% names(bold_df)))==FALSE)

{
stop("bin ids, taxon rank & site.cat fields have to be present in the dataset. Please re-check data")
Expand All @@ -94,7 +95,7 @@ gen.comm.mat<-function(bold.df,
{
# The following columns have to be present in the input data frame in order to get the results

if(any((c("bin_uri",taxon.rank,"lat","lon")%in% names(bold.df)))==FALSE)
if(any((c("bin_uri",taxon.rank,"lat","lon")%in% names(bold_df)))==FALSE)

{
stop("bin ids, taxon rank, latitude and longitude columns have to be present in the dataset for defining grids. Please re-check data")
Expand All @@ -107,9 +108,8 @@ gen.comm.mat<-function(bold.df,

# Obtaining the data from the fetched data for the transformation. NAs in site.cat and taxon.rank are removed

bin.comm.trial=bold.df%>%
convert_coord_2_lat_lon(.)%>%
dplyr::select(matches("bin_uri$",
bin.comm.trial=bold_df%>%
dplyr::select(matches("bin_uri$",
ignore.case=TRUE),
matches("lat$",
ignore.case=TRUE),
Expand Down

0 comments on commit bdba8a1

Please sign in to comment.