Space of a muser

Insight

Enjoy life, relish the moment!


R coding tricks

“[“ is actually a function in R. When using FUN=”[“, the first argument to “[“ is the current element of the list (being iterated over), ie, the object being subsetted. While the subsequent arguments are the indexes to “[“

Here is a trick to split string in vector and take the first part of the string.

1
y <- sapply(strsplit(x, ":"), "[", 1)
最近的文章

Tricks of shell

于  shell
更早的文章

Math equation test

于  Math
comments powered by Disqus