감동, 마음이 움직이는 것

[R] 본문

Tips (Utility, Computer Language, and etc.)

[R]

Struggler J. 2018. 8. 23. 06:49

script실행하기

https://stackoverflow.com/questions/18306362/run-r-script-from-command-line

Rscript test.R


combining string

https://stackoverflow.com/questions/7201341/how-can-two-strings-be-concatenated

name <- paste("apple", "banana", sep="")


getting argument

https://www.vscentrum.be/cluster-doc/software/r-cla-in-scripts

args <- commandArgs(TRUE)

r <- as.double(args[1])


========== This is my first R script ========== 

#library(package) acts like "import" in python and "include" in c

library(ggmuller)


#getting argument

args <- commandArgs(TRUE)

fidx <- args[1]


#read files

fname <- paste("pop", fidx, ".d", sep="") 

pop = read.table(fname)            

names(pop)[1]<-paste("Generation") //change the name of the data column

names(pop)[2]<-paste("Identity")

names(pop)[3]<-paste("Population")


fname <- paste("tree", fidx, ".d", sep="")

tree = read.table(fname)

names(tree)[1]<-paste("Parent")

names(tree)[2]<-paste("Identity")


#making ggmuller

Muller_df <- get_Muller_df(tree, pop)

Muller_pop_plot(Muller_df)

======================================== 


Important functions:

read.table(fname)         : read a file named fname         

names(arr)                    : list of data cols' names

paste(str1, str2, sep="") : return a string connecting str1 and str2 with seperator