convert_to_long_format: Reshape and simplify FORCIS data

View source: R/convert_to_long_format.R

convert_to_long_formatR Documentation

Reshape and simplify FORCIS data

Description

Reshapes FORCIS data by pivoting species columns into two columns: taxa (taxon names) and counts (taxon abundances). It converts wider data.frame to a long format.

Usage

convert_to_long_format(data)

Arguments

data

a data.frame, i.e. a FORCIS dataset, except for CPR North data.

Value

A data.frame reshaped in a long format.

Examples

# Attach the package ----
library("forcis")

# Import example dataset ----
file_name <- system.file(file.path("extdata", "FORCIS_net_sample.csv"), 
                         package = "forcis")

net_data <- read.table(file_name, dec = ".", sep = ";")

# Add 'data_type' column ----
net_data$"data_type" <- "Net"

# Dimensions of the data.frame ----
dim(net_data)

# Reshape data ----
net_data <- convert_to_long_format(net_data)

# Dimensions of the data.frame ----
dim(net_data)

# Column names ----
colnames(net_data)

FRBCesab/forcis documentation built on Oct. 25, 2024, 9:26 a.m.