This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sed '/pattern/ {$!N;d;}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sed '/pattern/,$d' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# here, inserting tab between | |
sed -r 's/(pattern1)(pattern2)/\1\t\2/g' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for just one object | |
deparse(substitute(my.object)) | |
#for a bunch of objects of the same class | |
# as string | |
dfs <- names(which(unlist(eapply(.GlobalEnv,is.data.frame)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set comment | |
comment(my_data_frame) <- "This is a comment" | |
# return comment | |
comment(my_data_frame) | |
[1] "This is a comment" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# be warned this is not a very proper way of R programming | |
# if you need to promote objects from inside function to | |
# parent environment better think twice | |
myfunc <- function(x) { | |
# do something like manipulating data and returning several df | |
# ......... | |
# ..... | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for f in *.* | |
do | |
name_is=$(basename ${f%.*}) | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ ${f: -4} == ".pdf" ];then ((pdffiles++)); fi | |
if [ ${f: -5} == ".docx" ];then ((docxfiles++)); fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [[ -z "${myVar// }" ]];then # if myVar is empty | |
# do something | |
fi | |
if [[ -n "${myVar// }" ]];then # if myVar is NOT empty | |
# do something | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [[ "${myVar}" =~ "myText" ]];then | |
# do something | |
fi |