【860】R programming related knowledge
Ref: R 字符串
Ref: R语言遍历文件和批量输出文件
setwd(dir)
getwd()
getwd
returns an absolute filepath representing the current working directory of the R process; setwd(dir)
is used to set the working directory to dir
.
head(x, n)
Returns the first or last parts of a vector, matrix, table, data frame or function. Since head()
and tail()
are generic functions, they may also have been extended to other classes.
This function is similar to df.head(n)
in python.
nchar(x)
It takes a character vector as an argument and returns a vector whose elements contain the sizes of the corresponding elements of x
.
length(x)
Get or set the length of vectors (including lists) and factors, and of any other R object for which a method has been defined.
This function is similar to len(x)
in python.
toupper()
/tolower()
substring(x, start, stop)
Extract or replace substrings in a character vector.
paste(..., sep = " ", collapse = NULL, recycle0 = FALSE)
Concatenate vectors after converting to character.
paste0(..., collapse = NULL, recycle0 = FALSE)
The sep
is set with nothing by default.
ls()
Return a vector of variables. rm()
Remove the specific variable.
c()
It is used to create a list to a vector.
append(x, values, after = length(x))
Add elements to a vector. The value will not add to x
directly.
> a = list() > for (i in c(1:10)) {a = append(a, i)}
grep
, grepl
, regexpr
, gregexpr
, regexec
and gregexec
search for matches to argument pattern
within each element of a character vector: they differ in the format of and amount of detail in the results.
list.files(path = ".", pattern = NULL, all.files = FALSE,
It produces a character vector of the names of files or directories in the named directory.
full.names = FALSE, recursive = FALSE,
ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)
list.dirs()
If wanting to batch files, for
loop can be used as follows,
1 2 3 | for (i in 1: length (files)) { file = read.table (files[i], sep= '\t' ) } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2022-07-18 【730】LaTeX添加自定义目录
2014-07-18 【144】重装系统那些事