diff --git a/DESCRIPTION b/DESCRIPTION index 561e7dd..1f0e749 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: Ternary -Version: 2.3.1 +Version: 2.3.1.9000 Title: Create Ternary and Holdridge Plots Description: Plots ternary diagrams (simplex plots / Gibbs triangles) and Holdridge life zone plots using the diff --git a/NEWS.md b/NEWS.md index 25ae709..9e84d92 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# Ternary v2.3.1.9000 (development) +- Document reading data into R in new users vignette. + # Ternary v2.3.1 (2024-02-06) - Improve support for `region` parameter. diff --git a/R/dot-TrianglePlot.R b/R/dot-TrianglePlot.R index 27a4a88..fbac657 100644 --- a/R/dot-TrianglePlot.R +++ b/R/dot-TrianglePlot.R @@ -47,9 +47,10 @@ tip.font, xlim, ylim, region, ...) { - direction <- 1L + (pmatch(tolower(point), c("right", "down", "left", "up", - "east", "south", "west", "north", - 2L, 3L, 4L, 1L)) %% 4L) + direction <- 1L + (pmatch(tolower(point[[1]]), + c("right", "down", "left", "up", + "east", "south", "west", "north", + "2", "3", "4", "1")) %% 4L) if (is.na(direction)) { stop("`point` must be one of up, down, left or right") } else { diff --git a/vignettes/new-users.Rmd b/vignettes/new-users.Rmd index fefdd01..1db7251 100644 --- a/vignettes/new-users.Rmd +++ b/vignettes/new-users.Rmd @@ -216,6 +216,45 @@ PlotTools::SpectrumLegend( ) ``` +# Your own data + +The next step is to try plotting your own data. There are many online +tutorials for loading data in a variety of formats into R. +Two of the most common cases are: + +- Reading data from an Excel file. Here you can use: +```r +# On first use only, install thje 'readxl' package +install.packages("readxl") + +# Load data into an object called `myData` +myData <- readxl::read_excel("path_to/your_excel_file.xlsx") + +# View the loaded data +View(myData) + +# View manual page for `read_excel` function, with details for advanced use +?read_excel +``` + +- Reading data from a delimited file, such as a `.csv`: + +```r +# Read data into an object called `myData` +myData <- read.csv("path_to/your_data_file.csv") + +# View the loaded data +View(myData) + +# For more flexibility - for instance for tab-separated data - see: +?read.table + +# Read data from a tab-separated file with a header row +myData <- read.table("path_to/your_data_file.txt", sep = "\t", header = TRUE) + +View(myData) +``` + # Where next For more complicated examples of usage, see the accompanying vignettes: