Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Software Design and Development for Statistical Data Analysis Packages in R, Lecture notes of Data Structures and Algorithms

Software design and development for statistical data analysis packages in R. It covers topics such as object-oriented programming in R, S3, S4, using C or C++ in an R function, creating a package, debugging and development tips. The document also provides an example of mass spectrometry imaging. useful for students studying computer science, statistics, and data analysis.

Typology: Lecture notes

2021/2022

Uploaded on 05/11/2023

palumi
palumi 🇺🇸

4.2

(13)

9 documents

1 / 16

Toggle sidebar

Related documents


Partial preview of the text

Download Software Design and Development for Statistical Data Analysis Packages in R and more Lecture notes Data Structures and Algorithms in PDF only on Docsity! Software Design and Development for Statistical Data Analysis Packages in R Kyle D. Bemis 4 March 2015 Purdue University Outline • Why plan your package? • Object-oriented programming in R • S3 • S4 • Using C or C++ in an R function • Creating a package • Example: Cardinal • Debugging and development tips Object-oriented programming in R • R is primarily a functional language • It has some object-oriented features • S3 • S4 S3 is simple • Less formal style of object-oriented programming • class(object) <- “Animal” • Objects are usually lists • Method dispatch based on naming scheme • foo.Animal <- function(…) { … } • Better for simpler data structures, such as results and output from analysis S4 is more complex • Formal class declaration • setClass(“Animal”, …) • Objects can be very complex data structures • Method dispatch implemented in “methods” package • setMethod(“foo”, “Animal”, function(…) {…}) • Better for more complex data structures, such as experiment workflows (genomics, proteomics, etc.) Build and install a package • From R: • install.packages(“MyPackage”, repos=NULL, type=“source”) • From command line: • R CMD build MyPackage • R CMD INSTALL MyPackage_0.1.tar.gz Example: Mass spectrometry imaging 200 400 600 800 1000 0 20 40 60 80 10 0 12 0 DESI Spectrum (x,y) = (33,80) MZ In te ns ity ● 20 40 60 80 100 120 10 20 30 40 50 60 70 M/Z = 887.67 x y thousands of mass spectra hundreds of ions MS image data structure x = 1, y = 1 x = 1, y = 2 x = 2, y = 1 x = 2, y = 2 m/z = 100 0.1 0.6 2.1 1.3 m/z = 101 3.4 0.8 2.3 1.7 m/z = 102 1.5 1.9 1.6 0.2 Debugging and development tips • Debugging in R: • browser() • options(error=recover) • Source control (Github, SVN, etc.) Questions? Thank you!
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved