get_population_df: Extract population data from a larger data frame

View source: R/SupplementaryFunctions.R

get_population_dfR Documentation

Extract population data from a larger data frame

Description

Extract population data from a larger data frame

Usage

get_population_df(df)

Arguments

df

Dataframe inclduing column names "Identity", "Parent", and either "Generation" or "Time"

Value

A dataframe comprising the population dynamics.

Author(s)

Rob Noble, robjohnnoble@gmail.com

See Also

get_edges

Examples

## Not run: 
# extract the adjacency matrix from the data frame:
edges <- get_edges(example_df)

# extract the populations (and any other attributes) from the data frame:
pop_df <- get_population_df(example_df)

# create data frame for plot:
Muller_df <- get_Muller_df(edges, pop_df)

require(RColorBrewer) # for the palette

# draw plot:
num_cols <- length(unique(Muller_df$RelativeFitness)) + 1
Muller_df$RelativeFitness <- as.factor(Muller_df$RelativeFitness)
Muller_plot(Muller_df, colour_by = "RelativeFitness", 
            palette = rev(colorRampPalette(brewer.pal(9, "YlOrRd"))(num_cols)), 
            add_legend = TRUE)

## End(Not run)


ggmuller documentation built on Feb. 16, 2023, 7:42 p.m.