Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Loops and Conditionals in R - short
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Corey Chivers
March 22, 2013
320
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Loops and Conditionals in R - short
Corey Chivers
March 22, 2013
More Decks by Corey Chivers
See All by Corey Chivers
Germination Project Data Science at Penn Medicine
cjbayesian
1
360
From Predictions to Decisions
cjbayesian
1
660
NIPS 2017 Summary
cjbayesian
1
1.7k
Validation des prévisions écologiques utilisant VMAPP: Validation métrique appliquée à des prévisions probabilistes
cjbayesian
1
180
From Whale Calls to Dark Matter - Competetive Data Science with R and Python
cjbayesian
0
1.5k
Introduction to Likelihood-based methods
cjbayesian
1
910
Implications of uncertainty: Bayesian modelling of aquatic invasive species spread
cjbayesian
0
400
Future Avenues for Open Data
cjbayesian
0
290
Montreal R Users Data Dive - Bike accidents
cjbayesian
0
130
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k
Making the Leap to Tech Lead
cromwellryan
135
10k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Music & Morning Musume
bryan
48
7.5k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
620
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
670
Building the Perfect Custom Keyboard
takai
2
950
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
560
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.3k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
760
Statistics for Hackers
jakevdp
799
230k
Transcript
•R is a full fledged programming language. It can do
loops and conditionals. i <- runif(1,0,100) if(i <= 50) { print(‘i is pretty small’) } Control Structures for(i in 1:100) { print(i) }
•A loop will be executed over and over. Control Structures
fruits<- c('apple','orange','banana','pear') for(fruit in fruits) { print(fruit) }
•Combining loops with conditionals can be very powerful. Control Structures
fruits<- c('apple','orange','banana','pear') for(fruit in fruits) { print(fruit) if(fruit == 'banana') print(paste(fruit,'rama!',sep='') }
Challenge 1) Print out all the numbers between 1 and
100, but if the number is a multiple of 3, print ‘fizz’ instead. 2) Extend your code so that for multiples of 5, it prints out ‘buzz’. HINT: To get the remainder of integer division, use %%. Ex: 4 9%%5