감동, 마음이 움직이는 것
[R ggmuller package] 본문
##########################
#References for ggmuller!#
##########################
1. main homepages:
https://cran.r-project.org/web/packages/ggmuller/
HowtoCite:
A BibTeX entry for LaTeX users is
@Manual{,
title = {ggmuller: Create Muller Plots of Evolutionary Dynamics},
author = {Robert Noble},
year = {2017},
note = {R package version 0.5.1},
url = {https://CRAN.R-project.org/package=ggmuller},
doi = 10.5281/zenodo.591304
}
UsefulPage: https://cran.r-project.org/web/packages/ggmuller/vignettes/ggmuller.html
2. blog:
https://thesefewlines.wordpress.com/2016/08/20/how-to-ggmuller/
######################
#Installing ggmuller in mac!#
######################
1. Install R
brew install r
https://stackoverflow.com/questions/20457290/installing-r-with-homebrew
2. Install R-studio (optional but recommended)
https://www.rstudio.com/products/rstudio/download/#download
http://web.cs.ucla.edu/~gulzar/rstudio/
3. Install the packages
From the manual of the ggmuller, we need some packages:
Imports dplyr (>= 0.7.0), ggplot2, ape
Suggests RColorBrewer, knitr, rmarkdown
Install packages in Rstudio:
(1) Click on the Packages tab in the bottom-right section and then click on install.
(2)The dialog box will appear. In the Install Packages dialog, write the package name you want to install under the Packages field and then click install. This will install the package you searched for or give you a list of matching package based on your package text.
4. For error message:
I got following error messages
During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_PAPER failed, using "C"
Solve by doing this:
1. Open Terminal
2. Write or paste in: defaults write org.R-project.R force.LANG en_US.UTF-8
3. Close Terminal
4. Start R
5. Understanding a warning message: The following objects are masked from ‘package:stats’:
6. Installing libgit2 (due to the dependency) <- to download the source from github
http://macappstore.org/libgit2/
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
brew install libgit2
7. Install ggmuller package
install.packages("devtools") # enables installation from github
library(devtools)
install_github("robjohnnoble/ggmuller")
library(ggmuller)
*Now we are done to install ggmuller!
###########################
#How to use a script in R!#
###########################
https://dzone.com/articles/how-to-write-r-script-explained-with-an-awesome-ex
https://statkclee.github.io/parallel-r/r-parallel-rscript-exec.html
Rstudio itself well provides the integrated environment to use a script. Especially, you can create a script and run in the Rstudio.
##########
#Example!#
##########
Example file is example.R.
To make ggmuller plot, you need two data: population data and phylogeny data.
The data structure of each file is:
#population data (3 cols)
Generation Identity Population
#phylogeny data (2 cols)
Parent Identity
############################
#read data from a file in R#
############################
http://www.r-tutor.com/r-introduction/data-frame/data-import
mydata = read.table("mydata.txt")
Changing column names of a data frame
names(newprice)[1]<-paste("premium")
https://stackoverflow.com/questions/6081439/changing-column-names-of-a-data-frame
'Tips (Utility, Computer Language, and etc.)' 카테고리의 다른 글
[gnuplot] symbols and special character (0) | 2018.09.18 |
---|---|
[gnuplot] key legend inverse order: set key invert (0) | 2018.09.17 |
[R] (0) | 2018.08.23 |
[c++] vector of vector (0) | 2018.08.23 |
[tips for presentation] especially for introduction (0) | 2018.07.18 |