Skip to content

Commit

Permalink
Reading data
Browse files Browse the repository at this point in the history
  • Loading branch information
ms609 committed Jul 5, 2024
1 parent 23ec29c commit 8c6d2c4
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 <doi:10.1126/science.105.2727.367> using the
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
7 changes: 4 additions & 3 deletions R/dot-TrianglePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
39 changes: 39 additions & 0 deletions vignettes/new-users.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8c6d2c4

Please sign in to comment.