KH.writeCSV: Write data set into a CSV file

Description Usage Arguments Note Examples

View source: R/Helper.R

Description

Write data set into a CSV file

Usage

1
KH.writeCSV(DT, csv_filename)

Arguments

DT

data.table. Data set ready to be written.

csv_filename

string. Full URL to the CSV file.

Note

If the file already exists, it would be overwritten without notice.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
set.seed(1000)
library(data.table)
d <- data.table(
group = sample(LETTERS[1:3], 10, replace = TRUE),
integer = rnorm(10, 5, 1),
decimal = rnorm(10, 5, 1)
)

KH.writeCSV(d, '/tmp/test_csv')
#[1] TRUE
KH.loadCSV('/tmp/test_csv')
#    group  integer  decimal
# 1:     A 4.614511 5.170057
# 2:     C 4.524132 5.155079
# 3:     A 5.719751 5.024932
# 4:     C 4.981494 2.953415
# 5:     B 3.626882 5.213154
# 6:     A 4.017572 7.670072
# 7:     C 4.445511 3.772984
# 8:     B 5.121381 5.834247
# 9:     A 4.879128 5.532572
#10:     A 3.663959 4.353175
}

ks465/r-utils documentation built on May 23, 2019, 5:07 p.m.