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
330
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
160
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
260
Montreal R Users Data Dive - Bike accidents
cjbayesian
0
130
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
160
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
230
Code Reviewing Like a Champion
maltzj
528
40k
Utilizing Notion as your number one productivity tool
mfonobong
4
290
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
130
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.6k
We Have a Design System, Now What?
morganepeng
55
8.1k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
360
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
220
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
Heart Work Chapter 1 - Part 1
lfama
PRO
6
35k
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