How to color categorical data markers?

0 votes

How to color categorical data markers in leaflet?

Sep 24 in Data Analytics by ch
• 1,470 points
12 views

1 answer to this question.

0 votes
Hey,

Use colorFactor function.

Check this example.

pal <- colorFactor(c("navy", "red"), domain = c("ship", "pirate"))
leaflet(df) %>% addTiles() %>%
  addCircleMarkers(
    radius = ~ifelse(type == "ship", 6, 10),
    color = ~pal(type),
    stroke = FALSE, fillOpacity = 0.5
  )
answered Sep 24 by Cherukuri
• 26,880 points

Related Questions In Data Analytics

0 votes
1 answer
0 votes
1 answer

How to convert a list of vectors with various length into a Data.Frame?

We can easily use this command as.data.frame(lapply(d1, "length< ...READ MORE

answered Apr 4, 2018 in Data Analytics by DeepCoder786
• 1,700 points
99 views
0 votes
2 answers

In data frame how to spilt strings into values?

You can do this using dplyr and ...READ MORE

answered Dec 4, 2018 in Data Analytics by Kalgi
• 41,170 points
54 views
0 votes
1 answer
0 votes
1 answer

plot map points from a dataframe

Hi Peter, Use below code. leaflet(df) %>% addTiles() %>% ...READ MORE

answered Sep 17 in Data Analytics by priya
14 views
0 votes
0 answers

How to add external markers in maps?

How to add external markers in maps? READ MORE

Sep 17 in Data Analytics by ruchitha
13 views
0 votes
0 answers

How to add legend or any text on the map in leaflet?

I'm new to leaflet and working on ...READ MORE

Sep 18 in Data Analytics by anonymous
• 26,880 points
17 views
0 votes
0 answers

fix the map area using leaflet and use ggplot

I created a map using leaflet and ...READ MORE

Sep 18 in Data Analytics by anonymous
• 26,880 points
9 views
0 votes
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21 in Data Analytics by anonymous
• 26,880 points
129 views
0 votes
2 answers

How to change column names of a Data frame?

Try this way - names(data frame) <- ...READ MORE

answered Aug 26 in Data Analytics by anonymous
• 26,880 points
79 views