Giter VIP home page Giter VIP logo

flowers's Introduction

flowers

CRAN status Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.

Flowers is a package for generating flower plots. It was derived from code from Jim Regetz at NCEAS, and then rewritten and extended by the OHI project. This package formalizes the approach into an easily re-usable function for generating custom flower plots for multiple scenarios.

Quick Start

This is a basic example which shows you how to create a flower plot from an appropriately structured data set:

library(flowers)
data(ohi)
plot_flower(ohi, "OHI Example Flower")

Currently plot_flower() expects particular column names and semantics, but this could be made more flexible. See the structure of OHI for an example. In particular, it uses columns score, weight, label, and category to create the plot.

By default the flower petals are colored proportionally to the score values as show in the OHI example above. One can provide a color palette (colors) to the plot_flower() function to control the gradient used.

The weight variable controls the relative widths of the petals, and should range from 0 to 1. The petal labels are taken from the label variable, and the grouping category labels are taken from the category variable. Other columns in the data frame are ignored.

#> 'data.frame':    13 obs. of  6 variables:
#>  $ goal    : chr  "FIS" "MAR" "AO" "NP" ...
#>  $ score   : num  50.5 NA 79.3 95.2 81.9 ...
#>  $ order   : num  1.1 1.2 2 3 5 6 7.1 7.2 8.1 8.2 ...
#>  $ weight  : num  0.5 0.5 1 1 1 1 0.5 0.5 0.5 0.5 ...
#>  $ category: chr  "Food Provision" "Food Provision" NA NA ...
#>  $ label   : chr  "Fisheries" "Mariculture" "Artisanal Needs" "Marine Mammal Harvest" ...

Alternatively, by setting fixed_colors = TRUE you can also color the petals with discrete colors determined by the label values, in which case you will likely want to provide a colors palette with at least as many colors as you have petals in the plot. Here’s an example with four fixed petals, in which we also provide only missing values to category so that no grouping labels are used:

    library(dplyr)
    df <- data.frame(order = c(1, 4, 3, 2),
                        score = c(90, 80, 70, 60),
                        weight = c(1, 1, 1, 1),
                        goal = c("F", "A", "I", "R"),
                        label = c("Findable", "Accessible", "Interoperable", "Reusable"),
                        category = c(NA, NA, NA, NA),
                        stringsAsFactors = FALSE) %>% arrange(order)
    d1_colors <- c( "#c70a61", "#ff582d", "#1a6379", "#60c5e4")
    plot_flower(df, title = "FAIR Metrics", fixed_colors=TRUE, colors = d1_colors)

Installation

You can install the development version of flowers from GitHub with:

devtools::install_github("mbjones/flowers")

You can install the released version of flowers from CRAN with:

install.packages("flowers")

nceas_footer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.