SlideShare a Scribd company logo
1 of 18
Basic use of R -Practice-
National Institute of Technology, Anan College, JAPAN
Yoshiki Satotani
Basic operation
Practice 1
1. Convert minutes into hours and minutes
• E.g. 123 -> 2:03, 255 -> 4:15
• Hint: use division and modulation
2. Find the number of digits of a number
• E.g. 12345 -> 5, 654321 -> 6
• Hint: 1-(10-1) -> 1 digit 10-(100-1) -> 2 digits ...
• Hint2: log10(1) = 0, log10(10) = 1, log10(100) = 2 ...
3. Find how many numbers which
1. Divisible by three
2. Smaller than or equal to1000
• Hint: colon operator (see help(‘:’))
• Hint2: length(): get length of a vector (see help(length))
Practice 1
4. Find how many numbers which
1. Divisible by three or five
2. Smaller than or equal to1000
• Hint: logical or operator for two vectors: see help(‘|’)
5. Solve:
•
𝑥 + 2𝑦 + 3𝑧 = 2
2𝑥 + 5𝑦 + 9𝑧 = 10
5𝑥 + 7𝑦 + 8𝑧 = 20
Practice 1
6. Load data frame from “apple_juice.csv” by
• aj = read.csv(“apple_juice.csv”) # take a look at "Load an Excel(csv) file"
and run these commands
1. summary(aj); summary(aj$pH) # summary function
2. mean(aj$pH)
3. median(aj$pH)
4. range(aj$pH)
5. var(aj$pH)
6. sd(aj$pH)
Graph
Practice 2
1. Draw these graphs:
1. y = x
2. y = cos(x)
3. y = asin(x)
4. y = atan(x)
5. y = log(x)
6. y = exp(x)
7. y = floor(x)
8. y = trunc(x / 60)
9. y = trunc(x %% 60)
10. y = floor(log10(x)) + 1
Practice 2
2. To draw multiple graphs, run
1. same axis:
• plot(x, y1, type=‘l’)
• lines(x, y2, type=‘l’) # just draw line over the graph
2. multiple axis:
• par(mfrow=c(1,2)) # create two graphs on a window
• plot(x, y1, type=‘l’) # draw first graph
• plot(x, y2, type=‘l’) # draw second graph
• par(mfrow=c(1,1)) # reset layout(single graph)
• Try 1. and 2. for x=seq(0,1,len=1000), y1=x^2, y2=exp(x)-1
Practice 2
3. From
apple_production.cs
v, make a chart of
apple production by
years, like
Practice 2
4. From apple_juice.csv,
make a historgram of
pH
Practice 2
5. From
apple_juice.csv,
make a boxplot that
• y axis: pH
• two boxes(first:
Growth=0, second:
Growth=1)
Practice 2
6. From
apple_production.cs
v, make a bar chart
of four varieties (Fuji,
Tsugaru, Orin, Jona
Gold) and Others
(Production – four
variety) in 2014
Practice 2
7. From
apple_production.cs
v, make a pie chart
of four varieties (Fuji,
Tsugaru, Orin, Jona
Gold) and Others
(Production – four
variety) in 2014
Programming
Practice 3
1. Scan a number and find whether the number is divisible
by three or not
• if so, print 'divisible by three‘
• if not, print 'not divisible by three‘
2. Scan a number and find if the number is divisible by
three and five
1. if divisible by only three, print 'divisible by three‘
2. if divisible by only five, print 'divisible by five‘
3. if divisible by three and five, print 'divisible by three and five‘
4. if divisible by neither three nor five, print 'not divisible by three
and five‘
Practice 3
3. With for statement and vector c('fuji', 'orin'), print
'delicious fuji' and 'delicious orin'.
• Hint: for string concatenation, use paste('foo', 'bar').
4. With while statement, ask a number till it is divisible by 3
5. (FizzBuzz) For number smaller than or equal to 100,
• print fizz if it is divisible by 3
• print buzz if it is divisible by 5
• print fizzbuzz if it is divisible by both 3 and 5
• print the number if is not divisible by both 3 and 5
i.e. 1 2 fizz 4 buzz fizz 7 8 fizz buzz...
Practice 3(advanced)
6. Make a function which you pass a word and returns
'delicious <your word>'. And try the function with some
words.
• Hint: use paste(‘delicious’, ‘your word’)
7. For vector, c('fuji', 'orin', ...), create a vector c('delicious
fuji', 'delicious orin', 'delicious ...')
• with function f = paste('delicious', x)
• sapply function(see help(sapply))
References & Acknowledgements
• from http://stackoverflow.com/questions/8145694/solving-
simultaneous-equations-with-r
• http://www.stat.ufl.edu/~winner/data/apple_juice.dat
• http://www.stat.ufl.edu/~winner/data/apple_juice.txt
• http://www.ringodaigaku.com/study/statistics/production_k
ind.html

More Related Content

What's hot (18)

Piecewise functions
Piecewise functions Piecewise functions
Piecewise functions
 
Functions
FunctionsFunctions
Functions
 
Piecewise Functions
Piecewise FunctionsPiecewise Functions
Piecewise Functions
 
Scope
ScopeScope
Scope
 
Alg1 review of writing equations of lines
Alg1 review of writing equations of linesAlg1 review of writing equations of lines
Alg1 review of writing equations of lines
 
Extreme Value
Extreme ValueExtreme Value
Extreme Value
 
2.7 Piecewise Functions
2.7 Piecewise Functions2.7 Piecewise Functions
2.7 Piecewise Functions
 
Function tables
Function tablesFunction tables
Function tables
 
Solve Eq Example 01
Solve Eq Example 01Solve Eq Example 01
Solve Eq Example 01
 
3.4 a linear programming
3.4 a linear programming3.4 a linear programming
3.4 a linear programming
 
Sketching derivatives
Sketching derivativesSketching derivatives
Sketching derivatives
 
Dr graphically worked
Dr graphically workedDr graphically worked
Dr graphically worked
 
Parent Function Project
Parent Function ProjectParent Function Project
Parent Function Project
 
Composition Of Functions
Composition Of FunctionsComposition Of Functions
Composition Of Functions
 
4.7 graph linear functions day 1
4.7 graph linear functions   day 14.7 graph linear functions   day 1
4.7 graph linear functions day 1
 
Square Roots And Sn Jeopardy
Square Roots And Sn  JeopardySquare Roots And Sn  Jeopardy
Square Roots And Sn Jeopardy
 
03 control
03 control03 control
03 control
 
Quadratic equation by four different methods
Quadratic equation by four different methodsQuadratic equation by four different methods
Quadratic equation by four different methods
 

Viewers also liked

Top 8 creative coordinator resume samples
Top 8 creative coordinator resume samplesTop 8 creative coordinator resume samples
Top 8 creative coordinator resume samples
garicjom
 
Acacia Builders Portfolio
Acacia Builders PortfolioAcacia Builders Portfolio
Acacia Builders Portfolio
Jason Elliott
 
IntJouCompAppl
IntJouCompApplIntJouCompAppl
IntJouCompAppl
Tim Minor
 
AcceptancePacket_Freshman
AcceptancePacket_FreshmanAcceptancePacket_Freshman
AcceptancePacket_Freshman
Danielle Duvick
 
Top 8 studio engineer resume samples
Top 8 studio engineer resume samplesTop 8 studio engineer resume samples
Top 8 studio engineer resume samples
tonychoper2105
 
JURANG PENCAPAIAN MATEMATIK MURID SEKOLAH RENDAH ATAU SEKOLAH MENENGAH
JURANG PENCAPAIAN MATEMATIK MURID SEKOLAH RENDAH ATAU SEKOLAH MENENGAHJURANG PENCAPAIAN MATEMATIK MURID SEKOLAH RENDAH ATAU SEKOLAH MENENGAH
JURANG PENCAPAIAN MATEMATIK MURID SEKOLAH RENDAH ATAU SEKOLAH MENENGAH
NurAlias91
 

Viewers also liked (17)

ICPIC 2013: The effect of improved hand hygiene compliance on nosocomial tran...
ICPIC 2013: The effect of improved hand hygiene compliance on nosocomial tran...ICPIC 2013: The effect of improved hand hygiene compliance on nosocomial tran...
ICPIC 2013: The effect of improved hand hygiene compliance on nosocomial tran...
 
Top 8 creative coordinator resume samples
Top 8 creative coordinator resume samplesTop 8 creative coordinator resume samples
Top 8 creative coordinator resume samples
 
Field Video with Sony NX5U
Field Video with Sony NX5UField Video with Sony NX5U
Field Video with Sony NX5U
 
Amrapali verona height ppt
Amrapali verona height pptAmrapali verona height ppt
Amrapali verona height ppt
 
Acacia Builders Portfolio
Acacia Builders PortfolioAcacia Builders Portfolio
Acacia Builders Portfolio
 
IntJouCompAppl
IntJouCompApplIntJouCompAppl
IntJouCompAppl
 
Gaur city
Gaur cityGaur city
Gaur city
 
Blog
BlogBlog
Blog
 
AcceptancePacket_Freshman
AcceptancePacket_FreshmanAcceptancePacket_Freshman
AcceptancePacket_Freshman
 
TIMMS & PISA
TIMMS & PISATIMMS & PISA
TIMMS & PISA
 
Top 8 studio engineer resume samples
Top 8 studio engineer resume samplesTop 8 studio engineer resume samples
Top 8 studio engineer resume samples
 
ใบงานสำรวจตนเอง M6
ใบงานสำรวจตนเอง M6ใบงานสำรวจตนเอง M6
ใบงานสำรวจตนเอง M6
 
50 phrasal-verbs-for-work-and-business
50 phrasal-verbs-for-work-and-business50 phrasal-verbs-for-work-and-business
50 phrasal-verbs-for-work-and-business
 
Top 8 medical office specialist resume samples
Top 8 medical office specialist resume samplesTop 8 medical office specialist resume samples
Top 8 medical office specialist resume samples
 
JURANG PENCAPAIAN MATEMATIK MURID SEKOLAH RENDAH ATAU SEKOLAH MENENGAH
JURANG PENCAPAIAN MATEMATIK MURID SEKOLAH RENDAH ATAU SEKOLAH MENENGAHJURANG PENCAPAIAN MATEMATIK MURID SEKOLAH RENDAH ATAU SEKOLAH MENENGAH
JURANG PENCAPAIAN MATEMATIK MURID SEKOLAH RENDAH ATAU SEKOLAH MENENGAH
 
Documentary proposal
Documentary proposal Documentary proposal
Documentary proposal
 
Android from zero
Android from zero Android from zero
Android from zero
 

Similar to Basic practice of R

Python for High School Programmers
Python for High School ProgrammersPython for High School Programmers
Python for High School Programmers
Siva Arunachalam
 
Thinking Functionally In Ruby
Thinking Functionally In RubyThinking Functionally In Ruby
Thinking Functionally In Ruby
Ross Lawley
 
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.pptALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
MargieCDeSagun
 
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES (1).ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES (1).pptALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES (1).ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES (1).ppt
JosephSPalileoJr
 
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.pptALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
JosephMuez2
 
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.pptALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
HazelJoySoriano
 
Higher nov 2008_p1old
Higher nov 2008_p1oldHigher nov 2008_p1old
Higher nov 2008_p1old
ybamary
 

Similar to Basic practice of R (20)

Python for High School Programmers
Python for High School ProgrammersPython for High School Programmers
Python for High School Programmers
 
Thinking Functionally In Ruby
Thinking Functionally In RubyThinking Functionally In Ruby
Thinking Functionally In Ruby
 
Teacher Lecture
Teacher LectureTeacher Lecture
Teacher Lecture
 
Mit6 094 iap10_lec04
Mit6 094 iap10_lec04Mit6 094 iap10_lec04
Mit6 094 iap10_lec04
 
Basic math akash
Basic math akashBasic math akash
Basic math akash
 
Powers and Exponents.pptx
Powers and Exponents.pptxPowers and Exponents.pptx
Powers and Exponents.pptx
 
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.pptALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
 
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES (1).ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES (1).pptALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES (1).ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES (1).ppt
 
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.pptALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
 
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.pptALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
ALLIED MATHEMATICS -II UNIT IV & UNIT V SEQUENCES AND SERIES.ppt
 
Stanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programmingStanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programming
 
Mit6 094 iap10_lec02
Mit6 094 iap10_lec02Mit6 094 iap10_lec02
Mit6 094 iap10_lec02
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Higher nov 2008_p1old
Higher nov 2008_p1oldHigher nov 2008_p1old
Higher nov 2008_p1old
 
Estimation, Approximation and Standard form
Estimation, Approximation and Standard formEstimation, Approximation and Standard form
Estimation, Approximation and Standard form
 
Python Tidbits
Python TidbitsPython Tidbits
Python Tidbits
 
Functional programming in ruby
Functional programming in rubyFunctional programming in ruby
Functional programming in ruby
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 

More from Yoshiki Satotani (7)

Basic use of Python (Practice)
Basic use of Python (Practice)Basic use of Python (Practice)
Basic use of Python (Practice)
 
Basic use of Python
Basic use of PythonBasic use of Python
Basic use of Python
 
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
 
PyLecture4 -Python Basics2-
PyLecture4 -Python Basics2-PyLecture4 -Python Basics2-
PyLecture4 -Python Basics2-
 
PyLecture2 -NetworkX-
PyLecture2 -NetworkX-PyLecture2 -NetworkX-
PyLecture2 -NetworkX-
 
PyLecture1 -Python Basics-
PyLecture1 -Python Basics-PyLecture1 -Python Basics-
PyLecture1 -Python Basics-
 
PyLecture3 -json-
PyLecture3 -json-PyLecture3 -json-
PyLecture3 -json-
 

Recently uploaded

Recently uploaded (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Basic practice of R

  • 1. Basic use of R -Practice- National Institute of Technology, Anan College, JAPAN Yoshiki Satotani
  • 3. Practice 1 1. Convert minutes into hours and minutes • E.g. 123 -> 2:03, 255 -> 4:15 • Hint: use division and modulation 2. Find the number of digits of a number • E.g. 12345 -> 5, 654321 -> 6 • Hint: 1-(10-1) -> 1 digit 10-(100-1) -> 2 digits ... • Hint2: log10(1) = 0, log10(10) = 1, log10(100) = 2 ... 3. Find how many numbers which 1. Divisible by three 2. Smaller than or equal to1000 • Hint: colon operator (see help(‘:’)) • Hint2: length(): get length of a vector (see help(length))
  • 4. Practice 1 4. Find how many numbers which 1. Divisible by three or five 2. Smaller than or equal to1000 • Hint: logical or operator for two vectors: see help(‘|’) 5. Solve: • 𝑥 + 2𝑦 + 3𝑧 = 2 2𝑥 + 5𝑦 + 9𝑧 = 10 5𝑥 + 7𝑦 + 8𝑧 = 20
  • 5. Practice 1 6. Load data frame from “apple_juice.csv” by • aj = read.csv(“apple_juice.csv”) # take a look at "Load an Excel(csv) file" and run these commands 1. summary(aj); summary(aj$pH) # summary function 2. mean(aj$pH) 3. median(aj$pH) 4. range(aj$pH) 5. var(aj$pH) 6. sd(aj$pH)
  • 7. Practice 2 1. Draw these graphs: 1. y = x 2. y = cos(x) 3. y = asin(x) 4. y = atan(x) 5. y = log(x) 6. y = exp(x) 7. y = floor(x) 8. y = trunc(x / 60) 9. y = trunc(x %% 60) 10. y = floor(log10(x)) + 1
  • 8. Practice 2 2. To draw multiple graphs, run 1. same axis: • plot(x, y1, type=‘l’) • lines(x, y2, type=‘l’) # just draw line over the graph 2. multiple axis: • par(mfrow=c(1,2)) # create two graphs on a window • plot(x, y1, type=‘l’) # draw first graph • plot(x, y2, type=‘l’) # draw second graph • par(mfrow=c(1,1)) # reset layout(single graph) • Try 1. and 2. for x=seq(0,1,len=1000), y1=x^2, y2=exp(x)-1
  • 9. Practice 2 3. From apple_production.cs v, make a chart of apple production by years, like
  • 10. Practice 2 4. From apple_juice.csv, make a historgram of pH
  • 11. Practice 2 5. From apple_juice.csv, make a boxplot that • y axis: pH • two boxes(first: Growth=0, second: Growth=1)
  • 12. Practice 2 6. From apple_production.cs v, make a bar chart of four varieties (Fuji, Tsugaru, Orin, Jona Gold) and Others (Production – four variety) in 2014
  • 13. Practice 2 7. From apple_production.cs v, make a pie chart of four varieties (Fuji, Tsugaru, Orin, Jona Gold) and Others (Production – four variety) in 2014
  • 15. Practice 3 1. Scan a number and find whether the number is divisible by three or not • if so, print 'divisible by three‘ • if not, print 'not divisible by three‘ 2. Scan a number and find if the number is divisible by three and five 1. if divisible by only three, print 'divisible by three‘ 2. if divisible by only five, print 'divisible by five‘ 3. if divisible by three and five, print 'divisible by three and five‘ 4. if divisible by neither three nor five, print 'not divisible by three and five‘
  • 16. Practice 3 3. With for statement and vector c('fuji', 'orin'), print 'delicious fuji' and 'delicious orin'. • Hint: for string concatenation, use paste('foo', 'bar'). 4. With while statement, ask a number till it is divisible by 3 5. (FizzBuzz) For number smaller than or equal to 100, • print fizz if it is divisible by 3 • print buzz if it is divisible by 5 • print fizzbuzz if it is divisible by both 3 and 5 • print the number if is not divisible by both 3 and 5 i.e. 1 2 fizz 4 buzz fizz 7 8 fizz buzz...
  • 17. Practice 3(advanced) 6. Make a function which you pass a word and returns 'delicious <your word>'. And try the function with some words. • Hint: use paste(‘delicious’, ‘your word’) 7. For vector, c('fuji', 'orin', ...), create a vector c('delicious fuji', 'delicious orin', 'delicious ...') • with function f = paste('delicious', x) • sapply function(see help(sapply))
  • 18. References & Acknowledgements • from http://stackoverflow.com/questions/8145694/solving- simultaneous-equations-with-r • http://www.stat.ufl.edu/~winner/data/apple_juice.dat • http://www.stat.ufl.edu/~winner/data/apple_juice.txt • http://www.ringodaigaku.com/study/statistics/production_k ind.html