This function takes a data frame and tests that the data frame is in valid raster format by checking that the data frame contains variables with the appropriate names. If the data frame is not in correct raster format, an error will be thrown that contains a message why the data is not in valid raster format.

test_valid_raster_format(raster_data)

Arguments

raster_data

A data frame or string specifying a file that will be checked to see if it is in valid raster format.

Value

Returns NULL if object is in valid raster format. Otherwise it will give an error message.

Examples

# This is valid raster data so the function will return no error message
raster_dir_name <- file.path(
  system.file("extdata", package = "NeuroDecodeR"),
  "Zhang_Desimone_7object_raster_data_small_rda"
)
file_name <- "bp1001spk_01A_raster_data.rda"
raster_full_path <- file.path(raster_dir_name, file_name)

test_valid_raster_format(raster_full_path)


# Binned data is not in raster format (it has an extra column called siteID) so
# checking if it is in raster format should return an error.

binned_file_name <- system.file(file.path("extdata", "ZD_150bins_50sampled.Rda"), 
                                package = "NeuroDecodeR")
try(test_valid_raster_format(binned_file_name))
#> Error in read_raster_data(raster_data) : 
#>   The raster data must be either a csv, rda, rds or mat file and have these
#>          corresponding file extensions