sm_transpose: Transpose a Wide Dataset to a Row-Based Format

View source: R/accessdb.R

sm_transposeR Documentation

Transpose a Wide Dataset to a Row-Based Format

Description

This function is called by sm_write_excel with option transpose = TRUE to generate a row-based tabular data format from a wide data frame in R that is suitable for exporting to Excel.

Usage

sm_transpose(data, date.format = "%d/%m/%Y")

Arguments

data

a wide format data frame where each column is a variable and the first variable uniquely identifies the data.

date.format

a format for date columns which is passed to format.Date. When transposing wide, dates are converted to character. The default R YYYY-MM-DD format for dates is often not recognized by Excel. By default dates are transformed to DD/MM/YYYY format which Excel (UK English) recognizes. Putting FALSE here does not transform dates into another format.

Value

A transposed data frame or data.table (the class of the input is preserved).

See Also

transpose, sm_pivot_wider, sm_write_excel, samadb

Examples

## Not run: 
sm_transpose(sm_data("ELECTRICITY"))

## End(Not run)

samadb documentation built on Aug. 21, 2025, 5:54 p.m.