alex_bn_lee

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

【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 sepis 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.

R Lists

append(x, values, after = length(x))Add elements to a vector. The value will not add to xdirectly.

> a = list()
> for (i in c(1:10)) {a = append(a, i)}

R Data Frames

R Plotting

grepgreplregexprgregexprregexec 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,
           full.names = FALSE, recursive = FALSE,
           ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)
It produces a character vector of the names of files or directories in the named directory.

list.dirs()

If wanting to batch files, forloop can be used as follows,

1
2
3
for   (i   in 1:  length  (files)) {
    file =   read.table  (files[i], sep=  '\t' )  
}

 

 

 

 

 

 

 

 

 

posted on   McDelfino  阅读(8)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2022-07-18 【730】LaTeX添加自定义目录
2014-07-18 【144】重装系统那些事
点击右上角即可分享
微信分享提示