Learn R Programming

bcputility (version 0.4.3)

mapDataTypes: Determine SQL Server data types from data frame. Follows SQL Server data type size constraints and chooses the smallest data type size.

Description

Determine SQL Server data types from data frame. Follows SQL Server data type size constraints and chooses the smallest data type size.

Usage

mapDataTypes(x, coltypes)

varChar(x)

varBinary(x)

int(x)

Value

character vector with names of columns

Arguments

x

data.frame object

coltypes

vector with names of columns to override the default data type mapping

Examples

Run this code

mapDataTypes(data.frame(
  int = 1:5L,
  numeric = seq(0, 1, length.out = 5),
  character = LETTERS[1:5],
  factor = paste(LETTERS[1:5], LETTERS[1:5], sep = ''),
  logical = c(TRUE, FALSE, TRUE, FALSE, TRUE),
  date = seq(Sys.Date() - 4, Sys.Date(), 1L),
  datetime = seq(Sys.time() - 5, Sys.time(), length.out = 5)
  )
)

Run the code above in your browser using DataLab