Basic Errors in the metadata?

I have written a code in R where lat and long are read from two tables and plotted with different colors on a map.

Both tables are structured as follows:

enter image description here

(I checked all enterties and they are all correct)

But the enviroment look like this (this is maybe the reason for the error)
enter image description here

The code looks like this:

install.packages('readxl')
library(readxl)

data_a <- read_excel('C:/Users/Location_map.xlsx', sheet = 'Core_Tops')
data_b <- read_excel('C:/Users/Location_map.xlsx', sheet = 'Tows')
lat_a <- data_a$Lat
lon_a <- data_a$Long
lat_b <- data_b$Lat
lon_b <- data_b$Long

# until this point the code workes very well :D


install.packages('leaflet')
library(leaflet)

map <- leaflet() %>%
  addTiles() %>%
  addMarkers(lng = lon_a, lat = lat_a, icon = ~colorIcon("blue",iconSize = c(20, 20))) %>%
  addMarkers(lng = lon_b, lat = lat_b, icon = ~colorIcon("red",iconSize = c(20, 20)))

map

When I execute it I get the following error message:

Error in UseMethod("metaData"): inapplicable method for 'metaData' applied to object of class "NULL"

What could be the cause? I can not find any answeres!

Before trying to figure out the meaning of the error message, convert the values of the character variables to numeric.


lat_a <- as.numeric(lat_a)
lon_a <- as.numeric(lon_a)

Data arriving from spreadsheets often show similar problems.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.