本文主要介绍如何在R中读取table数据和excel数据,以及保存数据框或者tibble。
读取数据
读取table数据
使用tidyverse
系列包中的readr
包中read_delim()
函数读取表格类数据,比基础函数read.table()
速度快约10倍,读取后的数据类型为tibble
形式。
tibble 是一种简单数据框,它对传统数据框的功能进行了一些修改,以便更易于使用。
函数:
read_delim(file,
delim, quote = "\"", escape_backslash = FALSE,escape_double = TRUE,
col_names = TRUE, col_types = NULL,locale = default_locale(),
na = c("", "NA"), quoted_na = TRUE,
comment = "", trim_ws = FALSE,
skip = 0,
n_max = Inf,guess_max = min(1000, n_max), progress = show_progress(),
skip_empty_rows = TRUE)
参数介绍:
示例:读取神经胶质瘤患者的临床数据。
data 'cilnical.txt',
delim = '\t',
col_names = T,
comment = '#',
na = c(&