Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
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
310
0
Share
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
340
From Predictions to Decisions
cjbayesian
1
620
NIPS 2017 Summary
cjbayesian
1
1.6k
Validation des prévisions écologiques utilisant VMAPP: Validation métrique appliquée à des prévisions probabilistes
cjbayesian
1
170
From Whale Calls to Dark Matter - Competetive Data Science with R and Python
cjbayesian
0
1.5k
Introduction to Likelihood-based methods
cjbayesian
1
860
Implications of uncertainty: Bayesian modelling of aquatic invasive species spread
cjbayesian
0
380
Future Avenues for Open Data
cjbayesian
0
270
Montreal R Users Data Dive - Bike accidents
cjbayesian
0
130
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
1
450
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
A better future with KSS
kneath
240
18k
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
Practical Orchestrator
shlominoach
191
11k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
A Soul's Torment
seathinner
6
2.8k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
810
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
190
Marketing to machines
jonoalderson
1
5.3k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
410
Designing for Performance
lara
611
70k
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