The presentation is a brief case study of R Programming Language. In this, we discussed the scope of R, Uses of R, Advantages and Disadvantages of the R programming Language.
This document provides an overview and introduction to using the statistical software R. It outlines R's interface, workspace, help system, packages, input/output functions, and how to reuse results. It also discusses downloading and installing R, basic functions and syntax, data manipulation techniques like sorting and merging, creating graphs, and performing statistical analyses such as t-tests, regression, ANOVA, and multiple comparisons. The document recommends several tutorials that provide more in-depth information on using R for statistical modeling, data analysis, and graphics.
This hands-on R course will guide users through a variety of programming functions in the open-source statistical software program, R. Topics covered include indexing, loops, conditional branching, S3 classes, and debugging. Full workshop materials available from http://projects.iq.harvard.edu/rtc/r-prog
This document provides an overview of R programming. It discusses the history and introduction of R, how to install R and R packages, key features of R including data handling and graphics, advantages such as being free and open source, and disadvantages such as average memory performance. It also outlines some real-world applications of R programming and predicts its continued importance in fields like data science, finance, and analytics.
This document provides an introduction and overview of using R for data visualization and analysis. It discusses installing both R and RStudio, basics of R programming including data types, vectors, matrices, data frames and control structures. Descriptive statistical analysis functions are also introduced. The document is intended to teach the fundamentals of the R programming language with a focus on data visualization and analysis.
This document provides an introduction to R, including what R is, how it compares to other statistical software packages, its advantages and disadvantages, how to install R, and options for R editors and graphical user interfaces (GUIs). It discusses R as a language for statistical computing and graphics, compares it to packages like SAS, Stata, and SPSS in terms of cost, usage mode, and prevalence. It outlines some of R's advantages like being free and open-source software with an active user community contributing packages, and some disadvantages like the learning curve and lack of a standard GUI.
This document discusses visualizing data in R using various packages and techniques. It introduces ggplot2, a popular package for data visualization that implements Wilkinson's Grammar of Graphics. Ggplot2 can serve as a replacement for base graphics in R and contains defaults for displaying common scales online and in print. The document then covers basic visualizations like histograms, bar charts, box plots, and scatter plots that can be created in R, as well as more advanced visualizations. It also provides examples of code for creating simple time series charts, bar charts, and histograms in R.
The presentation is a brief case study of R Programming Language. In this, we discussed the scope of R, Uses of R, Advantages and Disadvantages of the R programming Language.
This document provides an overview and introduction to using the statistical software R. It outlines R's interface, workspace, help system, packages, input/output functions, and how to reuse results. It also discusses downloading and installing R, basic functions and syntax, data manipulation techniques like sorting and merging, creating graphs, and performing statistical analyses such as t-tests, regression, ANOVA, and multiple comparisons. The document recommends several tutorials that provide more in-depth information on using R for statistical modeling, data analysis, and graphics.
This hands-on R course will guide users through a variety of programming functions in the open-source statistical software program, R. Topics covered include indexing, loops, conditional branching, S3 classes, and debugging. Full workshop materials available from http://projects.iq.harvard.edu/rtc/r-prog
This document provides an overview of R programming. It discusses the history and introduction of R, how to install R and R packages, key features of R including data handling and graphics, advantages such as being free and open source, and disadvantages such as average memory performance. It also outlines some real-world applications of R programming and predicts its continued importance in fields like data science, finance, and analytics.
This document provides an introduction and overview of using R for data visualization and analysis. It discusses installing both R and RStudio, basics of R programming including data types, vectors, matrices, data frames and control structures. Descriptive statistical analysis functions are also introduced. The document is intended to teach the fundamentals of the R programming language with a focus on data visualization and analysis.
This document provides an introduction to R, including what R is, how it compares to other statistical software packages, its advantages and disadvantages, how to install R, and options for R editors and graphical user interfaces (GUIs). It discusses R as a language for statistical computing and graphics, compares it to packages like SAS, Stata, and SPSS in terms of cost, usage mode, and prevalence. It outlines some of R's advantages like being free and open-source software with an active user community contributing packages, and some disadvantages like the learning curve and lack of a standard GUI.
This document discusses visualizing data in R using various packages and techniques. It introduces ggplot2, a popular package for data visualization that implements Wilkinson's Grammar of Graphics. Ggplot2 can serve as a replacement for base graphics in R and contains defaults for displaying common scales online and in print. The document then covers basic visualizations like histograms, bar charts, box plots, and scatter plots that can be created in R, as well as more advanced visualizations. It also provides examples of code for creating simple time series charts, bar charts, and histograms in R.
The goal of this workshop is to introduce fundamental capabilities of R as a tool for performing data analysis. Here, we learn about the most comprehensive statistical analysis language R, to get a basic idea how to analyze real-word data, extract patterns from data and find causality.
The document discusses importing and exporting data in R. It describes how to import data from CSV, TXT, and Excel files using functions like read.table(), read.csv(), and read_excel(). It also describes how to export data to CSV, TXT, and Excel file formats using write functions. The document also demonstrates how to check the structure and dimensions of data, modify variable names, derive new variables, and recode categorical variables in R.
The document introduces R programming and data analysis. It covers getting started with R, data types and structures, exploring and visualizing data, and programming structures and relationships. The aim is to describe in-depth analysis of big data using R and how to extract insights from datasets. It discusses importing and exporting data, data visualization, and programming concepts like functions and apply family functions.
This document provides an introduction to using R Studio for statistical analysis. It discusses how to install both R and R Studio on Windows and Mac systems. It then covers creating scripts and files in R Studio, basic R syntax including assigning values to variables, vectors, and strings. The document also demonstrates how to install and load packages to access additional functions, and how to access built-in datasets to practice working with data in R.
This document provides an agenda for an R programming presentation. It includes an introduction to R, commonly used packages and datasets in R, basics of R like data structures and manipulation, looping concepts, data analysis techniques using dplyr and other packages, data visualization using ggplot2, and machine learning algorithms in R. Shortcuts for the R console and IDE are also listed.
The document discusses an R programming module that will cover getting started with R, data types and structures, control flow and functions, and scalability. It compares R to MATLAB and Python, describing their similarities as interactive shells for data manipulation but noting differences in popularity across fields and open-source availability. Base graphics and ggplot2 for data visualization are introduced. Sample datasets are also mentioned.
This document provides an overview of various data structures in R including vectors, lists, factors, matrices, and data frames. It discusses how to create, subset, and coerce between these structures. It also covers handling missing data and common data type conversions. The document recommends several books and online resources for learning more about R programming and statistics.
In this module of python programming you will be learning about control statements. A control statement is a statement that determines whether other statements will be executed. An if statement decides whether to execute another statement, or decides which of two statements to execute. A loop decides how many times to execute another statement.
This document provides instructions for using R software for agricultural data analysis. It discusses downloading and installing R, loading and exploring data, performing common analyses like ANOVA and correlations, and using specialized packages for tasks like AMMI analysis. The document recommends exploring R's capabilities and using reliable packages suited for agricultural research.
this presentation is an introduction to R programming language.we will talk about usage, history, data structure and feathers of R programming language.
Regular expressions are a powerful tool for searching, matching, and parsing text patterns. They allow complex text patterns to be matched with a standardized syntax. All modern programming languages include regular expression libraries. Regular expressions can be used to search strings, replace parts of strings, split strings, and find all occurrences of a pattern in a string. They are useful for tasks like validating formats, parsing text, and finding/replacing text. This document provides examples of common regular expression patterns and methods for using regular expressions in Python.
R is a programming language and environment for statistical analysis and graphics. It has many built-in statistical and graphical techniques. R can be installed from CRAN and runs on Windows, MacOS, and UNIX systems. The basic R interface is the console, but RStudio provides an integrated development environment. In RStudio, you can write scripts, see outputs and plots, and access help and packages. Packages extend R's functionality through additional functions and data. Common data types in R include numeric, integer, character, factor, and logical. Vectors are the basic data structure, but R also supports matrices, arrays, data frames and lists.
This document discusses various data types and structures in R. It begins by defining data types as categories of values like numeric and character. Data structures are described as how data is stored, such as vectors, factors, matrices, data frames, and lists. Examples are provided for each structure showing how to create them and access their elements. The document concludes by demonstrating how to work with built-in datasets in R, including viewing, summarizing, and accessing their columns and rows.
As part of the GSPโs capacity development and improvement programme, FAO/GSP have organised a one week training in Izmir, Turkey. The main goal of the training was to increase the capacity of Turkey on digital soil mapping, new approaches on data collection, data processing and modelling of soil organic carbon. This 5 day training is titled โโTraining on Digital Soil Organic Carbon Mappingโโ was held in IARTC - International Agricultural Research and Education Center in Menemen, Izmir on 20-25 August, 2017.
The document provides an agenda for Day 2 of a training workshop on soil organic carbon mapping using R. The morning sessions focus on learning R basics like objects, commands, expressions and assignments through hands-on exercises and examples. The afternoon sessions cover R data types like vectors, data frames and lists, also through hands-on exercises. The objectives for Day 2 are listed as R basics and R data types.
The goal of this workshop is to introduce fundamental capabilities of R as a tool for performing data analysis. Here, we learn about the most comprehensive statistical analysis language R, to get a basic idea how to analyze real-word data, extract patterns from data and find causality.
The document discusses importing and exporting data in R. It describes how to import data from CSV, TXT, and Excel files using functions like read.table(), read.csv(), and read_excel(). It also describes how to export data to CSV, TXT, and Excel file formats using write functions. The document also demonstrates how to check the structure and dimensions of data, modify variable names, derive new variables, and recode categorical variables in R.
The document introduces R programming and data analysis. It covers getting started with R, data types and structures, exploring and visualizing data, and programming structures and relationships. The aim is to describe in-depth analysis of big data using R and how to extract insights from datasets. It discusses importing and exporting data, data visualization, and programming concepts like functions and apply family functions.
This document provides an introduction to using R Studio for statistical analysis. It discusses how to install both R and R Studio on Windows and Mac systems. It then covers creating scripts and files in R Studio, basic R syntax including assigning values to variables, vectors, and strings. The document also demonstrates how to install and load packages to access additional functions, and how to access built-in datasets to practice working with data in R.
This document provides an agenda for an R programming presentation. It includes an introduction to R, commonly used packages and datasets in R, basics of R like data structures and manipulation, looping concepts, data analysis techniques using dplyr and other packages, data visualization using ggplot2, and machine learning algorithms in R. Shortcuts for the R console and IDE are also listed.
The document discusses an R programming module that will cover getting started with R, data types and structures, control flow and functions, and scalability. It compares R to MATLAB and Python, describing their similarities as interactive shells for data manipulation but noting differences in popularity across fields and open-source availability. Base graphics and ggplot2 for data visualization are introduced. Sample datasets are also mentioned.
This document provides an overview of various data structures in R including vectors, lists, factors, matrices, and data frames. It discusses how to create, subset, and coerce between these structures. It also covers handling missing data and common data type conversions. The document recommends several books and online resources for learning more about R programming and statistics.
In this module of python programming you will be learning about control statements. A control statement is a statement that determines whether other statements will be executed. An if statement decides whether to execute another statement, or decides which of two statements to execute. A loop decides how many times to execute another statement.
This document provides instructions for using R software for agricultural data analysis. It discusses downloading and installing R, loading and exploring data, performing common analyses like ANOVA and correlations, and using specialized packages for tasks like AMMI analysis. The document recommends exploring R's capabilities and using reliable packages suited for agricultural research.
this presentation is an introduction to R programming language.we will talk about usage, history, data structure and feathers of R programming language.
Regular expressions are a powerful tool for searching, matching, and parsing text patterns. They allow complex text patterns to be matched with a standardized syntax. All modern programming languages include regular expression libraries. Regular expressions can be used to search strings, replace parts of strings, split strings, and find all occurrences of a pattern in a string. They are useful for tasks like validating formats, parsing text, and finding/replacing text. This document provides examples of common regular expression patterns and methods for using regular expressions in Python.
R is a programming language and environment for statistical analysis and graphics. It has many built-in statistical and graphical techniques. R can be installed from CRAN and runs on Windows, MacOS, and UNIX systems. The basic R interface is the console, but RStudio provides an integrated development environment. In RStudio, you can write scripts, see outputs and plots, and access help and packages. Packages extend R's functionality through additional functions and data. Common data types in R include numeric, integer, character, factor, and logical. Vectors are the basic data structure, but R also supports matrices, arrays, data frames and lists.
This document discusses various data types and structures in R. It begins by defining data types as categories of values like numeric and character. Data structures are described as how data is stored, such as vectors, factors, matrices, data frames, and lists. Examples are provided for each structure showing how to create them and access their elements. The document concludes by demonstrating how to work with built-in datasets in R, including viewing, summarizing, and accessing their columns and rows.
As part of the GSPโs capacity development and improvement programme, FAO/GSP have organised a one week training in Izmir, Turkey. The main goal of the training was to increase the capacity of Turkey on digital soil mapping, new approaches on data collection, data processing and modelling of soil organic carbon. This 5 day training is titled โโTraining on Digital Soil Organic Carbon Mappingโโ was held in IARTC - International Agricultural Research and Education Center in Menemen, Izmir on 20-25 August, 2017.
The document provides an agenda for Day 2 of a training workshop on soil organic carbon mapping using R. The morning sessions focus on learning R basics like objects, commands, expressions and assignments through hands-on exercises and examples. The afternoon sessions cover R data types like vectors, data frames and lists, also through hands-on exercises. The objectives for Day 2 are listed as R basics and R data types.
This document provides a brief introduction to basic R features such as starting R, entering commands, importing and manipulating data, creating vectors and data frames, and performing summary statistics and visualizations. Key points covered include starting R, entering commands and comments, arithmetic operations, creating sequences and assigning objects, importing data from files, subsetting and manipulating vectors and data frames, and creating histograms, boxplots and other plots. Examples are provided using the built-in FlightDelays data set.
R is a programming language and free software used for statistical analysis and graphics. It allows users to analyze data, build statistical models and visualize results. Key features of R include its extensive library of statistical and graphical methods, machine learning algorithms, and ability to handle large and complex data. R is widely used in academia and industry for data science tasks like data analysis, modeling, and communicating results.
R is a programming language and free software used for statistical analysis and graphics. It allows users to analyze data, build statistical models and visualize results. Key features of R include its extensive library of statistical and graphical methods, machine learning algorithms, and ability to handle large and complex data. R is widely used in academia and industry for data science tasks like data analysis, modeling, and communicating results.
R is a programming language and free software used for statistical analysis and graphics. It allows users to analyze data, create visualizations and build predictive models. Key features of R include its extensive library of statistical and machine learning methods, ability to handle large datasets, and functionality for data wrangling, modeling, visualization and communication of results. The document provides instructions on downloading and installing R and RStudio, loading and installing packages, and introduces basic R programming concepts like vectors, matrices, data frames and factors.
This document provides an introduction to Python programming concepts including data types, operators, control flow statements, functions and modules. It discusses the basic Python data types like integers, floats, booleans, strings, lists, tuples, dictionaries and sets. It also covers Python operators like arithmetic, assignment, comparison, logical and identity operators. Additionally, it describes control flow statements like if/else and for loops. Finally, it touches on functions, modules and input/output statements in Python.
R is a software package for data analysis and graphical representation. It provides functions, results of analysis as objects, and a flexible environment for model building. This document provides tutorials on basic R operations including computation, vectors, matrices, and graphics. Key functions introduced are cbind(), rbind(), seq(), rep(), and matrix() for creating and manipulating objects, and plot() for data visualization.
The document discusses various computer programming concepts in C language including data types, operators, control structures, functions, and algorithms. It provides an overview of different types of languages like machine language, assembly language, and high-level languages. It also explains concepts like variables, expressions, I/O functions, data structures and their implementation in C programs through examples. Flowcharts and algorithms for basic mathematical and logical problems are presented. Different loops and decision making statements supported in C like if-else, switch-case, for, while, do-while are described along with their syntax and usage.
This document provides an overview of basic R commands for data structures, data manipulation, and other foundational concepts. It introduces variables, functions, data types like vectors, data frames, and lists. Methods for reading external data files from CSV and Excel formats are demonstrated. Key functions covered include for loops, if/else conditional statements, and string manipulation tools like paste(), gsub(), and substr(). The goal is to explain R concepts and syntax in a straightforward manner that allows learning through examples and hands-on practice with real data problems.
R allows users to store data in objects that can be named and manipulated. Objects are created using <- and can contain vectors, matrices, or the output of functions. Functions take arguments as input and return output. Users can write their own functions to perform custom operations on data like randomly sampling values from a die vector.
A matrix is a two-dimensional rectangular data structure that can be created in R using a vector as input to the matrix function. The matrix function arranges the vector elements into rows and columns based on the number of rows and columns specified. Basic matrix operations include accessing individual elements and submatrices, computing transposes, products, and inverses. Matrices allow efficient storage and manipulation of multi-dimensional data.
Matlab is basically a high level language which has many specialized toolboxes for making things easier for us.
Matlab stands for MATrix LABoratory.
The first version of MATLAB was produced in the mid 1970s as a teaching tool. MATLAB started as an interactive program for doing matrix calculations.
MATLAB has now grown to a high level mathematical language that can solve integrals and differential equations numerically and plot a wide variety of two and three Dimensional graphs.
The expanded MATLAB is now used for calculations and simulation in companies and government labs ranging from aerospace, car design, signal analysis through to instrument control and financial analysis.
In practice, it provides a very nice tool to implement numerical method.
- The desktop includes these panels:
Current Folder โ Access your files.
Command Window โ Enter commands at the command line, indicated by the prompt (>>).
Workspace โ Explore data that you create or import from files.
- what we learn:
1- Introduction to Matlab.
2- MATLAB InstallationVersion 2018.
3- Assignment.
4- Operations in MATLAB.
5- Vectors and Matrices in MATLAB.
This document provides an overview of the C++ programming language. It discusses that C++ is a statically typed, compiled language that supports procedural and object-oriented programming. C++ was developed in 1979 by Bjarne Stroustrup as an enhancement to C with object-oriented capabilities. The document then covers various C++ concepts like data types, operators, program structure, and differences between C and C++.
This document discusses condition statements (if/else), functions that return values, user input using the input() function, logical operators, for loops used with strings, and string formatting. It provides examples of calculating total hours worked by employees, accessing characters in strings using indexes, common string methods like upper()/lower(), and basic cryptography techniques like the Caesar cipher. An exercise is given to write a program that encrypts a message using the Caesar cipher technique of rotating each letter by 3 positions.
This document provides instructions for learning R through an exercise on illusory correlation. It describes how to:
1. Download R and R Studio, an interface for R.
2. Learn basic R operations like assigning variables, using help functions, and writing scripts.
3. Generate simulated correlated data for two variables X and Y by using the mvrnorm function from the MASS package to specify the number of cases, means, and covariance matrix with a specified correlation between the two variables.
This document provides an overview of the basics of R. It discusses why R is useful, outlines its interface and workspace, describes how to get help and install packages, and explains some key concepts like objects, functions, and the search path. The document is intended to introduce new users to commonly used R functions and features to get started with the programming language.
This document provides an overview of the basics of R. It discusses why R is useful, outlines its interface and workspace, describes how to get help and install packages, and explains some key concepts like objects, functions, and the search path. The document is intended to introduce new users to commonly used R functions and features to get started with the programming language.
This document provides an overview of the basics of R including why R is used, tutorials and links for learning R, an overview of the R interface and workspace, and how to get help in R. It discusses that R is a free and open-source statistical programming language used for statistical analysis and graphics. It has a steep learning curve due to the interactive nature of analyzing data through chained commands rather than single procedures. Help is provided through a built-in system and various online tutorials.
Modeling in R Programming Language for Beginers.pptanshikagoel52
ย
This document provides an overview of the basics of R. It discusses why R is useful, outlines its interface and workspace, describes how to get help and install packages, and explains some key concepts like objects, functions, and the search path. The document is intended to introduce new users to commonly used R functions and features to get started with the programming language.
Agenda of the 5th NENA Soil Partnership meetingFAO
ย
The Fifth meeting of the Near East and North African (NENA) Soil Partnership will take place from 1-2 April 2019 in Cairo, Egypt. The objectives of the meeting are to consolidate the NENA Soil Partnership, review the work plan, organize activities to establish National Soil Information Systems, agree to launch a Regional Soil Laboratory for NENA, and strengthen networking. The meeting agenda includes discussions on soil information systems, a soil laboratory network, and implementing the Voluntary Guidelines for Sustainable Soil Management. The performance of the NENA Soil Partnership will also be assessed and future strategies developed.
This document summarizes the proceedings of the first meeting of the Global Soil Laboratory Network (GLOSOLAN). GLOSOLAN was established to harmonize soil analysis methods and strengthen the performance of laboratories through standardized protocols. The meeting discussed the role of National Reference Laboratories in promoting harmonization, and how GLOSOLAN is structured with regional networks feeding into the global network. Progress made in 2018 included registering over 200 laboratories, assessing capacities and needs, and establishing regional networks. The work plan for 2019 includes further developing regional networks, standard methods, a best practice manual, and the first global proficiency testing. The document concludes by outlining next steps to launch the regional network for North Africa and the Near East.
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.pptHenry Hollis
ย
The History of NZ 1870-1900.
Making of a Nation.
From the NZ Wars to Liberals,
Richard Seddon, George Grey,
Social Laboratory, New Zealand,
Confiscations, Kotahitanga, Kingitanga, Parliament, Suffrage, Repudiation, Economic Change, Agriculture, Gold Mining, Timber, Flax, Sheep, Dairying,
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...indexPub
ย
The recent surge in pro-Palestine student activism has prompted significant responses from universities, ranging from negotiations and divestment commitments to increased transparency about investments in companies supporting the war on Gaza. This activism has led to the cessation of student encampments but also highlighted the substantial sacrifices made by students, including academic disruptions and personal risks. The primary drivers of these protests are poor university administration, lack of transparency, and inadequate communication between officials and students. This study examines the profound emotional, psychological, and professional impacts on students engaged in pro-Palestine protests, focusing on Generation Z's (Gen-Z) activism dynamics. This paper explores the significant sacrifices made by these students and even the professors supporting the pro-Palestine movement, with a focus on recent global movements. Through an in-depth analysis of printed and electronic media, the study examines the impacts of these sacrifices on the academic and personal lives of those involved. The paper highlights examples from various universities, demonstrating student activism's long-term and short-term effects, including disciplinary actions, social backlash, and career implications. The researchers also explore the broader implications of student sacrifices. The findings reveal that these sacrifices are driven by a profound commitment to justice and human rights, and are influenced by the increasing availability of information, peer interactions, and personal convictions. The study also discusses the broader implications of this activism, comparing it to historical precedents and assessing its potential to influence policy and public opinion. The emotional and psychological toll on student activists is significant, but their sense of purpose and community support mitigates some of these challenges. However, the researchers call for acknowledging the broader Impact of these sacrifices on the future global movement of FreePalestine.
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumMJDuyan
ย
(๐๐๐ ๐๐๐) (๐๐๐ฌ๐ฌ๐จ๐ง ๐)-๐๐ซ๐๐ฅ๐ข๐ฆ๐ฌ
๐๐ข๐ฌ๐๐ฎ๐ฌ๐ฌ ๐ญ๐ก๐ ๐๐๐ ๐๐ฎ๐ซ๐ซ๐ข๐๐ฎ๐ฅ๐ฎ๐ฆ ๐ข๐ง ๐ญ๐ก๐ ๐๐ก๐ข๐ฅ๐ข๐ฉ๐ฉ๐ข๐ง๐๐ฌ:
- Understand the goals and objectives of the Edukasyong Pantahanan at Pangkabuhayan (EPP) curriculum, recognizing its importance in fostering practical life skills and values among students. Students will also be able to identify the key components and subjects covered, such as agriculture, home economics, industrial arts, and information and communication technology.
๐๐ฑ๐ฉ๐ฅ๐๐ข๐ง ๐ญ๐ก๐ ๐๐๐ญ๐ฎ๐ซ๐ ๐๐ง๐ ๐๐๐จ๐ฉ๐ ๐จ๐ ๐๐ง ๐๐ง๐ญ๐ซ๐๐ฉ๐ซ๐๐ง๐๐ฎ๐ซ:
-Define entrepreneurship, distinguishing it from general business activities by emphasizing its focus on innovation, risk-taking, and value creation. Students will describe the characteristics and traits of successful entrepreneurs, including their roles and responsibilities, and discuss the broader economic and social impacts of entrepreneurial activities on both local and global scales.
Gender and Mental Health - Counselling and Family Therapy Applications and In...PsychoTech Services
ย
A proprietary approach developed by bringing together the best of learning theories from Psychology, design principles from the world of visualization, and pedagogical methods from over a decade of training experience, that enables you to: Learn better, faster!
1. FAO- Global Soil
Partnership
Training on
Digital Soil Organic Carbon
Mapping
20-24 January 2018
Tehran/Iran
Yusuf YIGINI, PhD - FAO, Land and Water Division (CBL)
Guillermo Federico Olmedo, PhD - FAO, Land and Water Division (CBL)
3. We first introduce the idea of 'objects' and do
some very simple calculations using expressions.
The first session focuses and learns the basics.More
complicated analyses in the later sessions.
NOTE: R is case-sensitive!
4. R as a Calculator
> 6 + 98
[1] 104
> 90 * 44
[1] 3960
> 36 / 2
[1] 18
> 33 - 30
[1] 3
The most basic use of R is to use it as a simple calculator.
For example, enter:
5. R as a Calculator
> 1:40
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
[18] 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
[35] 35 36 37 38 39 40
You should see the result of the calculation as well as [1].
The [1] means first result. In this example it is the only
result. Other commands return multiple values. For
example, we can create a simple vector of values from 1
to 40 using:
6. R as a Calculator
> 3 * 5
[1] 15
> 3 - 8
[1] -5
> 12 / 4
[1] 3
> 23 + 34
[1] 57
Most of R commands deal with vectors and it is one of its
strengths - We shall see more of them soon.
Of course, R has all the basic mathematical operators. *
is used for multiplication, + for addition, / is for division, -
is for subtraction.
7. R Basics
> 3*5
> 3 * 5
> 3 * 5
R doesn't care about 'white space'.
White space is to separate variable names
8. R Basics
> 12 * 56 + 34
[1] 706
> 12 * (56 + 34)
[1] 1080
The order of precedence is standard and can be
controlled using parenthesis.
For example,
9. R Basics
> 3^2
[1] 9
> 12 %% 3
[1] 0
> 10 %% 3
[1] 1
> 10 %/% 3
[1] 3
You may use the symbol "^" to denote exponentiation 'little
hat'.We can also calculate the remainder, or modular, using
%%: Notice that the operators %% and %/% for integer
remainder and divide have higher precedence than multiply
and divide:
10. R Basics
> 1e2
[1] 100
> 1e3
[1] 1000
> 1e5
[1] 1e+05
Scientific notation is dealt with using e.
11. Exercise (10 mins)
1- Calculate square root of 765
2- Compute the volume of a sphere with radius 5:
the volume of a sphere is 4/3 times pi times the radius to
the third power
12. R Basics
> q()
Quitting from R, RStudio
To close R and quit you can either:
press ctrl + q
or type q()
13. > q
R Basics
Either way you probably get the option to save your
'workspace' (this can be turned off in the global options). The
workspace is a recording place for all your operations and
saved outputs.
If you save it the workspace will be automatically loaded next
time you start RStudio ( this can be disabled). Note that q()
has parenthesis. () it means that q is a FUNCTION .
If you just typed q you get the code for the function.
14. R Basics
Input value (known as 'arguments') for the
function goes between the parenthesis.
For example, to take the natural logarithm of a
value, you can use the log() function.
> log(10)
> log(100)
> log(340)
15. R Basics
> ?log
> log()
Error: argument "x" is missing, with no default
>
You can call the help content by using the question mark. Let's
look at the help page for the log() function.
The log() function expects at least one argument. If you don't
give it one, R returns an error (argument "x" is missing, with no
default):
16. R BasicsLots of other mathematical operations are available too, e.g.
exp(), sqrt(), tan() etc.
Operator Description Example
x + y y added to x 2 + 3 = 5
x โ y y subtracted from x 8 โ 2 = 6
x * y x multiplied by y 3 * 2 = 6
x / y x divided by y 10 / 5 = 2
x ^ y (or x ** y) x raised to the power y 2 ^ 5 = 32
x %% y remainder of x divided by y (x mod y)7 %% 3 = 1
x %/% y x divided by y but rounded down (integer divide) 7 %/% 3
= 2
pi is just pi :)
> pi
17. Trigonometric Functions
These functions give the obvious trigonometric functions.
They respectively compute the cosine, sine, tangent,
arc-cosine, arc-sine, arc-tangent, and the two-argument
arctangent.
So, you may want to try to calculate the cosine of an
angle of 120 degrees like this:
> cos(120)
[1] 0.814181
18. Trigonometric Functions
> cos(120)
[1] 0.814181
This code doesnโt give you the correct result,
however, because R always works with
angles in radians, not in degrees. Pay
attention to this fact; if you forget, the
resulting bugs may bite you hard!
20. R Basics
There are also some special values to be aware of:
Missing value indicator!
In R, missing values are represented by the symbol NA (Not
Available).
Impossible values (e.g., dividing by zero) are represented by
the symbol NaN (not a number). Unlike SAS, R uses the same
symbol for character and numeric data.
> 0/0
[1] NaN
> 4/0
[1] Inf
21. R Basics - NA
NA Can be very common when reading in your data.
It is important to note that NA does not mean 0!
Also, NAs propagate through calculations, for example:
> 3 + NA
[1] NA
22. R Basics
Incomplete commands!
If a command is incomplete, for example you don't' close a
parenthesis, R lets you know by displaying +:
+ missing bracket, eval=FALSE
> (2 + 3) * (3 + 1
+ )
[1] 20
23. Recording your work: working with scripts
Working with scripts is sometimes easier than typing stuff on the
console screen. It means you can reuse old scripts or borrow someone
else's.
It could also make your work reproducible. Writing a script is easy.
Instead of typing your R code on the console window, you can type your
code into the script editor window and save it (.R).
You can create a new script by clicking the button or through the File
menu - (try!).
Instead of typing directly into the console window, type it into the
source editor. You can then send lines of code to the console for
execution in RStudio (click on the button , or ctrl-enter).
> 5 * 4
We're still using R as a calculator only now it is a reproducible
calculator. You can save your script and use it again later (through
the File menu or use ctrl-s key combination).
You can save your script with *.R (e.g. my_code.R).
24. Comments begin with #. In computer programming, a comment is a
programmer-readable explanation or annotation in the source code of
a computer program.
They are added with the purpose of making the source code easier
for humans to understand, and are generally ignored by compilers
and interpreters.
Anything after # on the line is ignored and skipped by R.
R Basics - Commenting
25. Up to now we haven't been storing the results of our calculations, just
showing them to the screen.Storing things means we can reuse them later
on, allowing us to build up complex calculations.R stores everything as
an 'object'.Here we create an object called 'interest' for future use.
It stores the compound interest rate based on a 5% per year rate and a
30 year period.
> interest <- 1.05 ^ 30
R Basics - Objects
26. A couple of things to mention here:
1. In RStudio, in the Global Environment window, 'interest' has
appeared with a value equal to 1.09^30.
2. We used the 'assignment' operator <- to create the 'interest'
object and assign it a value.
Using '=' instead of '<-' is also supported.
Using <- implies an action rather than a relation.
We now have an object called 'interest'.
We can get at an object by typing the name.
R Basics - Objects
> interest
27. Some notes about naming:
R is case sensitive - interest is not the
same as Interest.
> Interest <- 10
> Interest
> interest
R Basics
28. You can include number and the . and _ symbols in the name.
# Names cannot start with Numbers..
#+ error name, eval=FALSE
> 30.interest <- 1.09 ^ 30
# Symbols may be used.
> .interest <- 1.09 ^ 30
A lot of guidance can be found about naming conventions
(capitals, underscores etc). Try to give your objects sensible
names that describe what they are! Someone else can understand
what they are.
R Basics
29. #### 15 minute exercise ####
An individual takes out a loan of value L at a monthly interest rate i.
The loan is to be paid back in n monthly installments of size M
where:
M = L *(i / (1 - (1+i)^-n))
Write some code to calculate the repayments, M.
1. Create objects for L, i and n (give them appropriate names).
2. Calculate M and store it in a new object.
Use these values:
The principal amount, L, is 1500.
The interest rate, i, is 0.01 (1%).
The number of payments, n, is 10.
What are the repayments if number of payments
increases to 20?
30. Objects of different types
So far the objects we have created have stored a single numerical
value.
e.g.
> interest
But we can do more than that. Objects can also be: vectors e.g.
1:11, matrices, arrays, lists, data.frames, characters,
functions...
For example:
> name <- "Table"
> name = "Table"
Use " or '
>name <- 'Table'
> name = 'Table'
> name
31. You can also change the type of an object.
> x <- "cake"
> x <- 10
> x
R is not 'strongly typed' meaning you can mix some types. However,
mixing some types can throw errors:
> name * 10
Error in name * 10 : non-numeric argument to binary operator
R Basics
32. How to check the object type?
Use the is() or class() functions:
> class(interest)
> is(interest)
Note that interest is a vector even though it only has one value.
Vectors are ubiquitous in R and one of the reasons that R is so
useful
R Basics
33. Boolean logic: TRUE or FALSE. Boolean data type is a data type with only
two possible values: true or false.
> 4 > 3
> 4 < 3
> 5 <= 9
Note that to test for equality you use two '=', '=='.
If you just one, then you perform an assignment
> x <- 3
> x == 4
> x = 4
> x
# All Boolean operators: AND (&), OR (|), NOT (!=) etc. are available.
> TRUE & TRUE
> TRUE | TRUE
> TRUE != TRUE
The use of logic becomes more obvious when we start using vectors and
data.frames.
34. We can see all the objects in the workspace by using ls().
> ls()
It has () so it's a function.
You can also use:
> objects()
R Basics
35. End of Session Exercises
Write an R script to perform the following
calculations:
1. Calculate the following and store the result
in an object: 1e6 * log(10) + (95 * 37.2)
36. 2. Use R to calculate the sine and
cosine of pi / 3 and store the result
End of Session Exercises
37. 3. Calculate the remainder after
dividing 56879 into 984325749
End of Session Exercises
38. 4. The equation to calculate the
volume of a circular cone is V = pi *
radius^2 * height / 3. What is the
volume of a cone with a radius of 10
m and a height of 30 m?
End of Session Exercises
39. 5. Write an equality test to see if
'wine' equals 'beer'.
End of Session Exercises