R Programming - Manuals
R Programming - Manuals
Programming in R
Author: Thomas Girke, UC Riverside
Contents
1 Introduction
2 R Basics
3 Code Editors for R
4 Integrating R with Vim and Tmux
5 Finding Help
6 Control Structures
6.1 Conditional Executions
6.1.1 Comparison Operators
6.1.2 Logical Operators
6.1.3 If Statements
6.1.4 Ifelse Statements
6.2 Loops
6.2.1 For Loop
6.2.2 While Loop
6.2.3 Apply Loop Family
6.2.3.1 For Two-Dimensional Data Sets: apply
6.2.3.2 For Ragged Arrays: tapply
6.2.3.3 For Vectors and Lists: lapply and sapply
6.2.4 Other Loops
6.2.5 Improving Speed Performance of Loops
7 Functions
8 Useful Utilities
8.1 Debugging Utilities
8.2 Regular Expressions
8.3 Interpreting Character String as Expression
8.4 Time, Date and Sleep
8.5 Calling External Software with System Command
8.6 Miscellaneous Utilities
9 Running R Programs
10 Object-Oriented Programming (OOP)
10.1 Define S4 Classes
manuals.bioinformatics.ucr.edu/home/programming-in-r 1/35
3/16/2020 R Programming - Manuals
Introduction
[ Slides ] [ R Code ]
General Overview
One of the main attractions of using the R (http://cran.at.r-project.org) environment is the ease with which users can write their
own programs and custom functions. The R programming syntax is extremely easy to learn, even for users with no
previous programming experience. Once the basic R programming control structures are understood, users can use the
R language as a powerful environment to perform complex custom analyses of almost any type of data.
R Basics
The R & BioConductor manual provides a general introduction to the usage of the R environment and its basic command
syntax.
manuals.bioinformatics.ucr.edu/home/programming-in-r 3/35
3/16/2020 R Programming - Manuals
Finding Help
Reference list on R programming (selection)
manuals.bioinformatics.ucr.edu/home/programming-in-r 4/35
3/16/2020 R Programming - Manuals
Control Structures
Conditional Executions
Comparison Operators
equal: ==
not equal: !=
greater/less than: > <
greater/less than or equal: >= <=
Logical Operators
and: &
or: |
not: !
If Statements
Syntax
Example
if(1==0) {
print(1)
} else {
print(2)
}
[1] 2
Table of Contents
Avoid inserting newlines between '} else'.
manuals.bioinformatics.ucr.edu/home/programming-in-r 5/35
3/16/2020 R Programming - Manuals
Ifelse Statements
Syntax
Example
Loops
The most commonly used loop structures in R are for, while and apply loops. Less common are repeat loops.
The break function is used to break out of loops, and next halts the processing of the current iteration and advances the
looping index.
For Loop
For loops are controlled by a looping vector. In every iteration of the loop one value in the looping vector is assigned to a
variable that can be used in the statements of the body of the loop. Usually, the number of loop iterations is defined by the
number of values stored in the looping vector and they are processed in the same order as they are stored in the looping
vector.
Syntax
manuals.bioinformatics.ucr.edu/home/programming-in-r 6/35
3/16/2020 R Programming - Manuals
for(variable in sequence) {
statements
}
Example
Example: condition*
x <- 1:10
z <- NULL
for(i in seq(along=x)) {
if(x[i] < 5) {
z <- c(z, x[i] - 1)
} else {
z <- c(z, x[i] / x[i])
}
}
z
[1] 0 1 2 3 1 1 1 1 1 1
Table of Contents
x <- 1:10
z <- NULL
for(i in seq(along=x)) {
if (x[i]<5) {
z <- c(z,x[i]-1)
} else {
stop("values need to be <5")
}
}
Error: values need to be <5
z
[1] 0 1 2 3
manuals.bioinformatics.ucr.edu/home/programming-in-r 7/35
3/16/2020 R Programming - Manuals
Table of Contents
While Loop
Similar to for loop, but the iterations are controlled by a conditional statement.
Syntax
while(condition) statements
Example
z <- 0
while(z < 5) {
z <- z + 2
print(z)
}
[1] 2
[1] 4
[1] 6
Table of Contents
Syntax
X: array, matrix or data.frame; MARGIN: 1 for rows, 2 for columns, c(1,2) for both; FUN: one or more functions; ARGs:
possible arguments for function
manuals.bioinformatics.ucr.edu/home/programming-in-r 8/35
3/16/2020 R Programming - Manuals
Example
Applies a function to array categories of variable lengths (ragged array). Grouping is defined by factor.
Syntax
Example
manuals.bioinformatics.ucr.edu/home/programming-in-r 9/35
3/16/2020 R Programming - Manuals
2 versicolor 5.936 2.770 4.260 1.326
3 virginica 6.588 2.974 5.552 2.026
Table of Contents
Both apply a function to vector or list objects. The function lapply returns a list, while sapply attempts to return the simplest
data object, such as vector or matrix instead of list.
Syntax
lapply(X, FUN)
sapply(X, FUN)
Example
$Sepal.Width
[1] 3.5 3.0 3.2
$Petal.Length
[1] 1.4 1.4 1.3
## Compute sum of each list component and return result as list
lapply(mylist, sum)
$Sepal.Length
[1] 14.7
$Sepal.Width
[1] 9.7
$Petal.Length
[1] 4.1
manuals.bioinformatics.ucr.edu/home/programming-in-r 10/35
3/16/2020 R Programming - Manuals
Table of Contents
Other Loops
Repeat Loop
Syntax
repeat statements
Loop is repeated until a break is specified. This means there needs to be a second statement to test whether or not to break
from the loop.
Example
z <- 0
repeat {
z <- z + 1
print(z)
if(z > 100) break()
}
Table of Contents
Looping over very large data sets can become slow in R. However, this limitation can be overcome by eliminating certain
operations in loops or avoiding loops over the data intensive dimension in an object altogether. The latter can be achieved by
performing mainly vector-to-vecor or matrix-to-matrix computations which run often over 100 times faster than the
corresponding for() or apply() loops in R. For this purpose, one can make use of the existing speed-optimized R functions
(e.g.: rowSums, rowMeans, table, tabulate) or one can design custom functions that avoid expensive R loops by
using vector- or matrix-based approaches. Alternatively, one can write programs that will perform all time consuming
computations on the C-level.
(1) Speed comparison of for loops with an append versus an inject step:
manuals.bioinformatics.ucr.edu/home/programming-in-r 11/35
3/16/2020 R Programming - Manuals
Table of Contents
The inject approach is 20-50 times faster than the append version.
(2) Speed comparison of apply loop versus rowMeans for computing the mean for each row in a large matrix:
(3) Speed comparison of apply loop versus vectorized approach for computing the standard deviation of each row:
manuals.bioinformatics.ucr.edu/home/programming-in-r 12/35
3/16/2020 R Programming - Manuals
(4) Example for computing the mean for any custom selection of columns without compromising the speed performance:
## In the following the colums are named according to their selection in myList
myList <- tapply(colnames(myMA), c(1,1,1,2,2,2,3,3,4,4), list)
myMAmean <- sapply(myList, function(x) rowMeans(myMA[,x]))
colnames(myMAmean) <- sapply(myList, paste, collapse="_")
myMAmean[1:4,]
C1_C2_C3 C4_C5_C6 C7_C8 C9_C10
1 0.0676799 -0.2860392 0.09651984 -0.7898946
2 -0.6120203 -0.7185961 0.91621371 1.1778427
3 0.2960446 -0.2454476 -1.18768621 0.9019590
4 0.9733695 -0.6242547 0.95078869 -0.7245792
## Alternative to achieve the same result with similar performance, but in a much less elegant way
myselect <- c(1,1,1,2,2,2,3,3,4,4) # The colums are named according to the selection stored in myselect
myList <- tapply(seq(along=myMA[1,]), myselect, function(x) paste("myMA[ ,", x, "]", sep=""))
myList <- sapply(myList, function(x) paste("(", paste(x, collapse=" + "),")/", length(x)))
myMAmean <- sapply(myList, function(x) eval(parse(text=x)))
colnames(myMAmean) <- tapply(colnames(myMA), myselect, paste, collapse="_")
myMAmean[1:4,]
C1_C2_C3 C4_C5_C6 C7_C8 C9_C10
1 0.0676799 -0.2860392 0.09651984 -0.7898946
2 -0.6120203 -0.7185961 0.91621371 1.1778427
3 0.2960446 -0.2454476 -1.18768621 0.9019590
4 0.9733695 -0.6242547 0.95078869 -0.7245792
Table of Contents
Functions
A very useful feature of the R environment is the possibility to expand existing functions and to easily write custom functions.
In fact, most of the R software can be viewed as a series of R functions.
manuals.bioinformatics.ucr.edu/home/programming-in-r 13/35
3/16/2020 R Programming - Manuals
myfct(arg1=..., arg2=...)
Table of Contents
Syntax Rules for Functions
General
Functions are defined by (1) assignment with the keyword function, (2) the declaration of arguments/variables
(arg1, arg2, ...) and (3) the definition of operations (function_body) that perform computations on the
provided arguments. A function name needs to be assigned to call the function (see below).
Naming
Function names can be almost anything. However, the usage of names of existing functions should be avoided.
Arguments
It is often useful to provide default values for arguments (e.g.:arg1=1:10). This way they don't need to be
provided in a function call. The argument list can also be left empty (myfct <- function() { fct_body })
when a function is expected to return always the same value(s). The argument '...' can be used to allow one
function to pass on argument settings to another.
Function body
The actual expressions (commands/operations) are defined in the function body which should be enclosed by
braces. The individual commands are separated by semicolons or new lines (preferred).
Calling functions
Functions are called by their name followed by parentheses containing possible argument names. Empty
parenthesis after the function name will result in an error message when a function requires certain arguments to
be provided by the user. The function name alone will print the definition of a function.
Scope
Variables created inside a function exist only for the life time of a function. Thus, they are not accessible outside of
the function. To force variables in functions to exist globally, one can use this special assignment operator: '<<-'. If
a global variable is used in a function, then the global variable will be masked only within the function.
myfct(2, 5) # the argument names are not necessary, but then the order of the specified values becomes important
myfct(x1=2) # does the same as before, but the default value '5' is used in this case
Table of Contents
myfct2(x1=5, opt_arg=30:20) # a custom vector is used instead when the optional argument (opt_arg) is specified
my function returns:
[1] 6.0 5.8 5.6 5.4 5.2 5.0 4.8 4.6 4.4 4.2 4.0
Table of Contents
Return
The evaluation flow of a function may be terminated at any stage with the return function. This is often used in
combination with conditional evaluations.
Stop
To stop the action of a function and print an error message, one can use the stop function.
Warning
To print a warning message in unexpected situations without aborting the evaluation flow of a function, one can use
the function warning("...").
Useful Utilities
Debugging Utilities
Several debugging utilities are available for R. The most important utilities
are: traceback(), browser(), options(error=recover), options(error=NULL) and debug().
The Debugging in R page provides an overview of the available resources.
Regular Expressions
R's regular expression utilities work similar as in other languages. To learn how to use them in R, one can consult the main
help page on this topic with ?regexp. The following gives a few basic examples.
The grep function can be used for finding patterns in strings, here letter A in vector month.name.
month.name[grep("A", month.name)]
[1] "April" "August"
Table of Contents
Example for using regular expressions to substitute a pattern by another one using the sub/gsub function with a back
reference. Remember: single escapes '\' need to be double escaped '\\' in R.
manuals.bioinformatics.ucr.edu/home/programming-in-r 16/35
3/16/2020 R Programming - Manuals
x <- gsub("(a)", "\\1_", month.name[1], perl=TRUE) # performs substitution with back reference which inserts in this
example a '_' character
x
[1] "Ja_nua_ry"
strsplit(x, "_") # splits string on inserted character from above
[[1]]
[1] "Ja" "nua" "ry"
paste(rev(unlist(strsplit(x, NULL))), collapse="") # reverses character string by splitting first all characters into
vector fields and then collapsing them with paste
[1] "yr_aun_aJ"
Table of Contents
Example for importing specific lines in a file with a regular expression. The following example demonstrates the retrieval of
specific lines from an external file with a regular expression. First, an external file is created with the cat function, all lines of
this file are imported into a vector with readLines, the specific elements (lines) are then retieved with the grep function, and
the resulting lines are split into vector fields with strsplit.
manuals.bioinformatics.ucr.edu/home/programming-in-r 17/35
3/16/2020 R Programming - Manuals
system.time(ls()) # returns CPU (and other) times that an expression used, here ls()
user system elapsed
0 0 0
date() # returns the current system date and time
[1] "Wed Dec 11 15:31:17 2012"
Sys.sleep(1) # pause execution of R expressions for a given number of seconds (e.g. in loop)
Table of Contents
system("...") # provide under '...' command to run external software e.g. Perl, Python, C++ programs
Table of Contents
x <- shell("dir", intern=T) # reads current working directory and assigns to file
shell.exec("C:/Documents and Settings/Administrator/Desktop/my_file.txt") # opens file with associated program
Table of Contents
Miscellaneous Utilities
(1) Batch import and export of many files.
In the following example all file names ending with *.txt in the current directory are first assigned to a list (the '$' sign is used
to anchor the match to the end of a string). Second, the files are imported one-by-one using a for loop where the original
names are assigned to the generated data frames with the assign function. Consult help with ?read.table to understand
arguments row.names=1 and comment.char = "A". Third, the data frames are exported using their names for file naming
manuals.bioinformatics.ucr.edu/home/programming-in-r 18/35
3/16/2020 R Programming - Manuals
close(x)
mylines <- res[grep("Theoretical pI/Mw:",
res)]
myresult <- c(myresult, as.numeric(gsub(".*/ ", "",
mylines)))
print(myresult)
Sys.sleep(1) # halts process for one sec to give web service a
break
}
final <- data.frame(Pep=myentries,
MW=myresult)
cat("\n The MW values for my peptides
are:\n")
final
Pep MW
1 MKWVTFISLLFLFSSAYS 2139.11
2 MWVTFISLL 1108.60
3 MFISLLFLFSSAYS 1624.82
Table of Content
manuals.bioinformatics.ucr.edu/home/programming-in-r 19/35
3/16/2020 R Programming - Manuals
Running R Programs
(1) Executing an R script from the R console
source("my_script.R")
Table of Contents
(2.1) Syntax for running R programs from the command-line. Requires in first line of my_script.R the following
statement: #!/usr/bin/env Rscript
$ Rscript my_script.R # or just ./myscript.R after making file executable with 'chmod +x my_script.R'
All commands starting with a '$' sign need to be executed from a Unix or Linux shell.
(2.2) Alternatively, one can use the following syntax to run R programs in BATCH mode from the command-line.
The output file lists the commands from the script file and their outputs. If no outfile is specified, the name used is that
of infile and .Rout is appended to outfile. To stop all the usual R command line information from being written to the
outfile, add this as first line to my_script.R file: options(echo=FALSE). If the command is run like this R CMD BATCH --
no-save my_script.R, then nothing will be saved in the .Rdata file which can get often very large. More on this can be
found on the help pages: $ R CMD BATCH --help or ?BATCH.
######################
myarg <- commandArgs()
manuals.bioinformatics.ucr.edu/home/programming-in-r 20/35
3/16/2020 R Programming - Manuals
print(iris[1:myarg[6], ])
######################
In the given example the number 10 is passed on from the command-line as an argument to the R script which is used to
return to STDOUT the first 10 rows of the iris sample data. If several arguments are provided, they will be interpreted as one
string that needs to be split it in R with the strsplitfunction.
This script doesn't need to have executable permissions. Use the following qsub command to send this shell script to the
Linux cluster from the directory where the R script my_script.R is located. To utilize several CPUs on the Linux cluster, one
can divide the input data into several smaller subsets and execute for each subset a separate process from a dedicated
directory.
$ qsub my_script.sh
Table of Contents
Here is a short R script that generates the required files and directories automatically and submits the jobs to the
nodes: submit2cluster.R. For more details, see also this 'Tutorial on Parallel Programming in R' by Hanna Sevcikova
(5) Submitting jobs to Torque or any other queuing/scheduling system via the BatchJobs package. This package provides
one of the most advanced resources for submitting jobs to queuing systems from within R. A related package
is BiocParallel from Bioconductor which extends many functionalities of BatchJobs to genome data analysis. Useful
documentation for BatchJobs: Technical Report, GitHub page, Slide Show, Config samples.
library(BatchJobs)
loadConfig(conffile = ".BatchJobs.R")
## Loads configuration file. Here .BatchJobs.R containing just this line:
## cluster.functions <- makeClusterFunctionsTorque("torque.tmpl")
## The template file torque.tmpl is expected to be in the current working
manuals.bioinformatics.ucr.edu/home/programming-in-r 21/35
3/16/2020 R Programming - Manuals
## director. It can be downloaded from here:
## https://github.com/tudo-r/BatchJobs/blob/master/examples/cfTorque/simple.tmpl
Define S4 Classes
(A) Define S4 Classes with setClass() and new()
(C) A more generic way of creating class instances is to define an initialization method (details below)
myobj@a # The '@' extracts the contents of a slot. Usage should be limited to internal functions!
initialize(.Object=myobj, a=as.matrix(cars[1:3,])) # Creates a new S4 object from an old one.
# removeClass("myclass") # Removes object from current session; does not apply to associated methods.
Table of Contents
(E) Inheritance: allows to define new classes that inherit all properties (e.g. data slots, methods) from their existing parent
classes
Slot "b":
[1] "a" "b" "c" "d"
Slot "c":
[1] 1 2 3 4
Slot "d":
[1] 4 3 2 1
getClass("myclass1")
Class "myclass1" [in ".GlobalEnv"]
Slots:
Name: a b
Class: character character
Table of Contents
manuals.bioinformatics.ucr.edu/home/programming-in-r 24/35
3/16/2020 R Programming - Manuals
The argument contains allows to extend existing classes; this propagates all slots of parent classes.
(G) Virtual classes are constructs for which no instances will be or can be created. They are used to link together classes
which may have distinct representations (e.g. cannot inherit from each other) but for which one wants to provide similar
functionality. Often it is desired to create a virtual class and to then have several other classes extend it. Virtual classes can be
defined by leaving out the representation argument or including the class VIRTUAL:
setClass("myVclass")
setClass("myVclass", representation(a = "character", "VIRTUAL"))
Table of Contents
getClass("myclass")
getSlots("myclass")
slotNames("myclass")
extends("myclass2")
manuals.bioinformatics.ucr.edu/home/programming-in-r 25/35
3/16/2020 R Programming - Manuals
[,1] [,2] [,3] [,4] [,5]
[1,] 1 11 21 31 41
[2,] 2 12 22 32 42
...
Table of Contents
setMethod(f="[", signature="myclass",
definition=function(x, i, j, ..., drop) {
x@a <- x@a[i,j]
manuals.bioinformatics.ucr.edu/home/programming-in-r 26/35
3/16/2020 R Programming - Manuals
return(x)
})
myobj[1:2,] # Standard subsetting works now on new class
An object of class "myclass"
Slot "a":
a b c d e
a 999 999 21 31 41
b 2 12 22 32 42
...
Table of Contents
(F) Define a graphical plotting function and allow user to access it with generic plot function
manuals.bioinformatics.ucr.edu/home/programming-in-r 27/35
3/16/2020 R Programming - Manuals
showMethods(class="myclass")
findMethods("randomize")
getMethod("randomize", signature="myclass")
existsMethod("randomize", signature="myclass")
Building R Packages
To get familiar with the structure, building and submission process of R packages, users should carefully read the
documentation on this topic available on these sites:
Note: this is an optional but very convenient function to get started with a new package. The given example will create a
directory named mypackagecontaining the skeleton of the package for all functions, methods and classes defined in the R
script(s) passed on to the code_files argument. The basic structure of the package directory is described here. The
manuals.bioinformatics.ucr.edu/home/programming-in-r 28/35
3/16/2020 R Programming - Manuals
package directory will also contain a file named 'Read-and-delete-me' with the following instructions for completing the
package:
Edit the help file skeletons in man, possibly combining help files for multiple functions.
Edit the exports in NAMESPACE, and add necessary imports.
Put any C/C++/Fortran code in src.
If you have compiled code, add a useDynLib() directive to NAMESPACE.
Run R CMD build to build the package tarball.
Run R CMD check to check the package tarball.
Read Writing R Extensions for more information.
(B) Once a package skeleton is available one can build the package from the command-line (Linux/OS X):
Linux:
install.packages("mypackage_1.0.tar.gz", repos=NULL)
Table of Contents
OS X:
manuals.bioinformatics.ucr.edu/home/programming-in-r 29/35
3/16/2020 R Programming - Manuals
package directory:
$ mkdir tempdir
$ R CMD INSTALL -l tempdir mypackage_1.0.tar.gz
$ cd tempdir
$ zip -r mypackage mypackage
## The resulting mypackage.zip archive can be installed under Windows like this:
install.packages("mypackage.zip", repos=NULL)
Table of Contents
This procedure only works for packages which do not rely on compiled code (C/C++). Instructions to fully build an R package
under Windows can be found here and here.
Add new functions, methods and classes to the script files in the ./R directory in your package
Add their names to the NAMESPACE file of the package
Additional *.Rd help templates can be generated with the prompt*() functions like this:
The resulting *.Rd help files can be edited in a text editor and properly rendered and viewed from within R like this:
library(tools)
Rd2txt("./mypackage/man/myfct.Rd") # renders *.Rd files as they look in final help pages
checkRd("./mypackage/man/myfct.Rd") # checks *.Rd help file for problems
Table of Contents
The best way of sharing an R package with the community is to submit it to one of the main R package repositories, such as
CRAN or Bioconductor. The details about the submission process are given on the corresponding repository submission
pages:
Submitting to Bioconductor (guidelines, submission, svn control, build/checks release, build/checks devel)
Submitting to CRAN
manuals.bioinformatics.ucr.edu/home/programming-in-r 30/35
3/16/2020 R Programming - Manuals
R Programming Exercises
Exercise Slides
[ Slides ] [ Exercises ] [ Additional Exercises ]
Download on of the above exercise files, then start editing this R source file with a programming text editor, such as Vim,
Emacs or one of the R GUI text editors. Here is the HTML version of the code with syntax coloring.
Sample Scripts
## (4) Same as above, but file naming by index data frame. This way one can organize file names by external table.
name_df <- data.frame(Old_name=sort(files), New_name=sort(month.abb))
for(i in seq(along=name_df[,1])) {
x <- read.table(as.vector(name_df[i,1]), header=TRUE, row.names=1, comment.char = "A", sep="\t")
x <- data.frame(x, sum=apply(x, 1, sum), mean=apply(x, 1, mean))
Table of Contents
Sample script to perform large-scale expression array analysis with complex queries: lsArray.R. To demo what the script does,
run it like this:
source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/lsArray.R")
Table of Contents
Script to plot feature maps of genes or chromosomes: featureMap.R. To demo what the script does, run it like this:
source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/featureMap.txt")
Table of Contents
Includes sequence batch import, sub-setting, pattern matching, AA Composition, NEEDLE, PHYLIP, etc. The script
'sequenceAnalysis.R' demonstrates how R can be used as a powerful tool for managing and analyzing large sets of biological
sequences. This example also shows how easy it is to integrate R with the EMBOSS project or other external programs. The
script provides the following functionality:
To demonstrate the utilities of the script, users can simply execute it from R with the following source command:
source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/sequenceAnalysis.txt")
Table of Contents
Functions for importing sequences into R, retrieving reverse and complement of nucleotide sequences, pattern searching,
positional parsing and exporting search results in HTML format: patternSearch.R. To demo what the script does, run it like
this:
source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/patternSearch.R")
Table of Contents
Functions for finding over-represented words in sets of DNA, RNA or protein sequences: wordFinder.R. To demo what the
script does, run it like this:
source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/wordFinder.R")
Table of Contents
Script 'translateDNA.R' for translating NT sequences into AA sequences (required codon table). To demo what the script does,
run it like this:
source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/translateDNA.R")
Table of Contents
manuals.bioinformatics.ucr.edu/home/programming-in-r 33/35
3/16/2020 R Programming - Manuals
Script for importing and subsetting SDF files: sdfSubset.R. To demo what the script does, run it like this:
source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/sdfSubset.R")
Table of Contents
Script for importing BibTeX databases into R, retrieving the individual references with a full-text search function and viewing
the results in R or in HubMed: BibTex.R. To demo what the script does, run it like this:
source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/BibTex.R")
Table of Contents
This script calculates monthly and annual mortgage or loan payments, generates amortization tables and plots the
results: mortgage.R. To demo what the script does, run it like this:
source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/mortgage.R")
Table of Contents
Apply the above information to write a function that calculates for a set of DNA sequences their GC content and generates their reverse and
complement. Here are some useful commands that can be incorporated in this function:
This site was accessed web analytics times (detailed access stats).
Đăng nhập | Hoạt động gần đây của trang web | Báo cáo lạm dụng | Trang in | Được cung cấ
manuals.bioinformatics.ucr.edu/home/programming-in-r 35/35