The document discusses making function calls in R. It explains that a function call requires a function name and arguments within parentheses. Arguments can be named or unnamed. When arguments are named, their position does not matter, but when unnamed, their values must be provided in the correct order to match the function's expected arguments. The document provides examples of making function calls using the mean() function to illustrate named versus unnamed arguments and the importance of argument position when unnamed. It also discusses other function components like the function name, default argument values, and anonymous functions.
Fast formula queries for functions, contexts, db is and packagesFeras Ahmad
This document provides SQL queries to extract fast formula related data from underlying tables, including:
1) A query that retrieves fast formula functions and their underlying packages.
2) A query that lists fast formulas with their FF code, description, edit status, formula text and other metadata.
3) A query that extracts database items (DBIs) from a process order, including the module, group, user name, data type, definition and contexts used.
4) A query that retrieves fast formula contexts by formula type.
The document discusses SQL database concepts including:
- The SQL data definition language allows specification of schemas, integrity constraints, and other metadata.
- Relations are defined using CREATE TABLE statements which specify attributes and their data types.
- Basic queries use SELECT, FROM, and WHERE clauses to retrieve and filter tuples from one or more relations.
- Integrity constraints like PRIMARY KEY and NOT NULL can be defined to enforce data validity.
- SQL supports operations like JOIN, aggregation, sorting, and more.
1. Recursion is a programming technique where a method calls itself to solve smaller instances of the same problem. This document discusses examples of using recursion to calculate triangular numbers, factorials, binary search, and the Towers of Hanoi puzzle.
2. Mergesort is presented as a recursive algorithm for sorting an array. It works by recursively splitting the array in half and merging the sorted halves.
3. Various examples of Java programs are provided that implement recursive solutions to problems like calculating triangular numbers, factorials, binary search, Towers of Hanoi, and mergesort.
The document discusses different sorting algorithms: bubble sort, selection sort, and insertion sort. It explains how each algorithm would sort a group of baseball players by height through examples and pseudocode. Bubble sort works by repeatedly swapping adjacent elements if they are in the wrong order until the list is fully sorted. Selection sort finds the minimum element and swaps it into the sorted portion of the list. Insertion sort iterates through the list and inserts each element into the sorted portion, shifting elements as needed. Java code examples are provided to implement each sorting algorithm.
This document contains a summary of structures in C programming language. It defines what a structure is, how to declare and define a structure with members, and how to access structure members using the dot operator. It also discusses nested structures, arrays of structures, and provides an example of a program that uses a structure to prepare student mark statements. Key points covered include declaring and defining structures, accessing structure members, nested structures, arrays of structures, and an example program to print student marks statements using a structure.
The document discusses different types of functions in MATLAB:
1) Functions allow grouping code to perform tasks and operate in their own workspace separately from the base workspace. They can accept multiple inputs and outputs.
2) Anonymous functions can be defined inline without a file using the @ syntax.
3) Primary functions must be in a file but can call sub-functions defined there as well.
4) Nested functions are defined within another function and share its workspace. Private functions reside in a private subfolder and are only visible locally.
5) Global variables can be shared between functions by declaring them globally at the start of relevant files.
This document discusses function parameters and argument passing in Python. It explains that parameters exist only within the function they are defined in, and values are assigned when calling the function. It demonstrates positional, keyword, and mixed argument passing, and shows how default values can be set for parameters. Functions can be called by passing arguments in different orders or specifying keywords. Key points are that parameters transfer information to functions, and various argument passing techniques exist.
Fast formula queries for functions, contexts, db is and packagesFeras Ahmad
This document provides SQL queries to extract fast formula related data from underlying tables, including:
1) A query that retrieves fast formula functions and their underlying packages.
2) A query that lists fast formulas with their FF code, description, edit status, formula text and other metadata.
3) A query that extracts database items (DBIs) from a process order, including the module, group, user name, data type, definition and contexts used.
4) A query that retrieves fast formula contexts by formula type.
The document discusses SQL database concepts including:
- The SQL data definition language allows specification of schemas, integrity constraints, and other metadata.
- Relations are defined using CREATE TABLE statements which specify attributes and their data types.
- Basic queries use SELECT, FROM, and WHERE clauses to retrieve and filter tuples from one or more relations.
- Integrity constraints like PRIMARY KEY and NOT NULL can be defined to enforce data validity.
- SQL supports operations like JOIN, aggregation, sorting, and more.
1. Recursion is a programming technique where a method calls itself to solve smaller instances of the same problem. This document discusses examples of using recursion to calculate triangular numbers, factorials, binary search, and the Towers of Hanoi puzzle.
2. Mergesort is presented as a recursive algorithm for sorting an array. It works by recursively splitting the array in half and merging the sorted halves.
3. Various examples of Java programs are provided that implement recursive solutions to problems like calculating triangular numbers, factorials, binary search, Towers of Hanoi, and mergesort.
The document discusses different sorting algorithms: bubble sort, selection sort, and insertion sort. It explains how each algorithm would sort a group of baseball players by height through examples and pseudocode. Bubble sort works by repeatedly swapping adjacent elements if they are in the wrong order until the list is fully sorted. Selection sort finds the minimum element and swaps it into the sorted portion of the list. Insertion sort iterates through the list and inserts each element into the sorted portion, shifting elements as needed. Java code examples are provided to implement each sorting algorithm.
This document contains a summary of structures in C programming language. It defines what a structure is, how to declare and define a structure with members, and how to access structure members using the dot operator. It also discusses nested structures, arrays of structures, and provides an example of a program that uses a structure to prepare student mark statements. Key points covered include declaring and defining structures, accessing structure members, nested structures, arrays of structures, and an example program to print student marks statements using a structure.
The document discusses different types of functions in MATLAB:
1) Functions allow grouping code to perform tasks and operate in their own workspace separately from the base workspace. They can accept multiple inputs and outputs.
2) Anonymous functions can be defined inline without a file using the @ syntax.
3) Primary functions must be in a file but can call sub-functions defined there as well.
4) Nested functions are defined within another function and share its workspace. Private functions reside in a private subfolder and are only visible locally.
5) Global variables can be shared between functions by declaring them globally at the start of relevant files.
This document discusses function parameters and argument passing in Python. It explains that parameters exist only within the function they are defined in, and values are assigned when calling the function. It demonstrates positional, keyword, and mixed argument passing, and shows how default values can be set for parameters. Functions can be called by passing arguments in different orders or specifying keywords. Key points are that parameters transfer information to functions, and various argument passing techniques exist.
Computers use their memory for storing instructions of the programs and the values of the variables. Memory is a sequential collection of storage cells. Each cell has an address associated with it. Whenever we declare a variable, the system allocates, somewhere in the memory, a memory location and a unique address is assigned to this location.c pointers lecture
The document is a workshop on functions that contains:
1) Definitions of functions and their key properties such as domains, ranges, and classifications as injective, surjective, and bijective.
2) Examples of determining if functions are injective based on their graphs.
3) Exercises involving graphing functions, classifying relations as functions, and determining function types.
4) A reference section listing resources on functions and trigonometry.
The document discusses structures in C programming. It defines structures as a way to pack together logically related data items of different types. Some key points:
- Structures allow defining custom data types that group together members of integer, float, character, and other standard types.
- Structure variables are declared and members accessed using the dot operator. Arrays of structures can also be defined.
- Structures can be initialized in various ways and passed to functions by value or by reference.
- Nested structures, where one structure is defined as a member of another, are also supported.
The document also covers arrays of structures, passing structures to functions, user-defined data types using typedef and enums,
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4Philip Schwarz
(download for flawless image quality) Can a left fold ever work over an infinite list? What about a right fold? Find out.
Learn about the other two functions used by functional programmers to implement mathematical induction: iterating and scanning.
Learn about the limitations of the accumulator technique and about tupling, a technique that is the dual of the accumulator trick.
. Relational Database Design 1.1. Introduction to Anomalies 1.2. Functional dependencies 1.3. Decomposition 1.4. Introduction to Normalization 1.4.1. First Normal Form 1.4.2. Second Normal Form 1.4.3. Third Normal Form 1.4.4. BCNF
Python tutorial notes for all the beginners. It is covered with core topics in python with example programs. It is useful for all types of students (school, college (lower and higher level)) and also for teachers, lecturers, assistant professors, and professors.
The document discusses recursion and provides examples of recursive algorithms and data structures including arithmetic series, Fibonacci sequence, binary search, and mergesort. Recursion involves breaking a problem down into smaller sub-problems until they can be solved directly, and combining the solutions to solve the original problem. Examples demonstrate how recursion uses function calls to solve problems by dividing them into base cases and recursively calling itself on smaller instances.
This document provides an introduction to key SQL concepts like nulls, group by, order by, distinct, and aggregates. It explains that nulls represent missing or unknown values and cannot be compared to other values. The group by clause groups result rows based on columns and can be used with aggregates. Order by sorts result rows based on columns. Distinct removes duplicate rows from results. Aggregates like count, sum, and average perform calculations across rows in a group.
This document contains study material prepared by D.GAYA, Assistant Professor of Computer Science at Pondicherry University Community College, for the subject "Programming with Visual Basic". It covers modules on functions and procedures, including passing arguments by value and reference, arrays, user-defined data types, and using dialog boxes. It provides examples of creating and calling both functions and sub procedures in Visual Basic, and passing arguments to procedures.
The document discusses structures and unions in C programming. It defines a structure as a user-defined data type that allows storing heterogeneous data under a single name. Structures contain members that can be accessed using the dot operator. Arrays of structures allow storing multiple records of the same type. Structures can be nested by defining a structure member within another structure. Unions allow storing different types of data in the same memory location, but only one member can be accessed at a time. Examples are provided to demonstrate defining, declaring, and accessing structure and union variables as well as nested structures.
Functions can take parameters which are names listed in the function's definition. Parameters allow functions to accept arguments when called, and those arguments can then be used inside the function. For example, a function called sayHello is defined to take one parameter called name, and when called with the argument "Dan", it outputs an alert of "Hi, Dan".
This document provides an overview of SQL commands and concepts. It discusses:
1) SPUFI and how it allows direct SQL input in TSO.
2) SQL commands including DDL, DML, TCL, DCL, JOINs, VIEWs, CURSORs, TRIGGERs, FUNCTIONS, and PROCEDUREs.
3) Examples are provided for many of the commands to demonstrate their usage.
This presentation focus on the basic concept of pointers. so that students can easily understand. it also contains basic operations performed by pointer variables and implementation using c language.
Este documento describe varios métodos para resolver sistemas de ecuaciones lineales, incluyendo el método de eliminación de Gauss, el método de Gauss-Jordan, la descomposición LU, la factorización de Cholesky, y métodos iterativos como los métodos de Gauss-Seidel y Jacobi. Explica los pasos involucrados en cada método y provee ejemplos para ilustrar cómo funcionan.
Este documento discute varios factores de motivación en el trabajo, incluyendo teorías como la jerarquía de necesidades de Maslow y la teoría de los dos factores. También cubre destrezas comunicacionales como usar lenguaje simple y directo, y evitar distracciones. Finalmente, identifica tres causas potenciales de conflicto: intereses opuestos, falta de reglas claras, y falta de disposición para resolver problemas.
Technology Solutions is a privately held business established in 2003 that specializes in telecommunications installation services and construction contracting. They provide a wide range of services including broadband cable installation for homes and businesses as well as infrastructure installation like directional boring and splicing. They are focused on meeting customer needs by valuing their employees and trained staff.
presentation delivered at SMART event
please note this presentation was delivered as speaker support material and is intended for reference by attendees not for use as a stand-alone resource
The document provides a summary of commodity price movements on February 4th for several major commodities including the S&P GSCI Total Return Index, gold, silver, copper, crude oil (WTI and Brent), and natural gas. It lists the opening price, daily price range, weekly, monthly, quarterly, and yearly price ranges as well as a brief description for each commodity. All commodities decreased or remained relatively flat on the day except for gold and silver which increased around 1-2%.
Este documento presenta tres algoritmos secuenciales. El primero pide los datos personales de una persona (nombre, apellido, cédula, profesión) y los imprime. El segundo pide dos números e imprime la suma, resta, multiplicación y división. El tercero calcula el salario de un trabajador en base a sus horas trabajadas y la tarifa por hora, aplicando un aumento del 50% a la tarifa para horas extras.
The document discusses the culture at a new company called Tikoo Culture. It explains that Tikoo wants to build a culture where employees feel valued, respected, heard, and supported. This is because having a positive company culture is important for attracting and retaining top talent. The document outlines some initial efforts Tikoo is taking to define and promote their culture, such as having employees identify words that describe being "Tikool" and implementing rewards programs to recognize employees who demonstrate the company's cultural values.
This document provides an overview of working with dates and times in R. It discusses recognizing date-time objects in R, getting the current date and time, and creating date-time objects using the POSIXct and POSIXlt classes. Methods for converting character and numeric data to date-time objects are presented, along with extracting parts of date-time objects and performing computations. The goal is to introduce the reader to key date and time functionality in base R.
Computers use their memory for storing instructions of the programs and the values of the variables. Memory is a sequential collection of storage cells. Each cell has an address associated with it. Whenever we declare a variable, the system allocates, somewhere in the memory, a memory location and a unique address is assigned to this location.c pointers lecture
The document is a workshop on functions that contains:
1) Definitions of functions and their key properties such as domains, ranges, and classifications as injective, surjective, and bijective.
2) Examples of determining if functions are injective based on their graphs.
3) Exercises involving graphing functions, classifying relations as functions, and determining function types.
4) A reference section listing resources on functions and trigonometry.
The document discusses structures in C programming. It defines structures as a way to pack together logically related data items of different types. Some key points:
- Structures allow defining custom data types that group together members of integer, float, character, and other standard types.
- Structure variables are declared and members accessed using the dot operator. Arrays of structures can also be defined.
- Structures can be initialized in various ways and passed to functions by value or by reference.
- Nested structures, where one structure is defined as a member of another, are also supported.
The document also covers arrays of structures, passing structures to functions, user-defined data types using typedef and enums,
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4Philip Schwarz
(download for flawless image quality) Can a left fold ever work over an infinite list? What about a right fold? Find out.
Learn about the other two functions used by functional programmers to implement mathematical induction: iterating and scanning.
Learn about the limitations of the accumulator technique and about tupling, a technique that is the dual of the accumulator trick.
. Relational Database Design 1.1. Introduction to Anomalies 1.2. Functional dependencies 1.3. Decomposition 1.4. Introduction to Normalization 1.4.1. First Normal Form 1.4.2. Second Normal Form 1.4.3. Third Normal Form 1.4.4. BCNF
Python tutorial notes for all the beginners. It is covered with core topics in python with example programs. It is useful for all types of students (school, college (lower and higher level)) and also for teachers, lecturers, assistant professors, and professors.
The document discusses recursion and provides examples of recursive algorithms and data structures including arithmetic series, Fibonacci sequence, binary search, and mergesort. Recursion involves breaking a problem down into smaller sub-problems until they can be solved directly, and combining the solutions to solve the original problem. Examples demonstrate how recursion uses function calls to solve problems by dividing them into base cases and recursively calling itself on smaller instances.
This document provides an introduction to key SQL concepts like nulls, group by, order by, distinct, and aggregates. It explains that nulls represent missing or unknown values and cannot be compared to other values. The group by clause groups result rows based on columns and can be used with aggregates. Order by sorts result rows based on columns. Distinct removes duplicate rows from results. Aggregates like count, sum, and average perform calculations across rows in a group.
This document contains study material prepared by D.GAYA, Assistant Professor of Computer Science at Pondicherry University Community College, for the subject "Programming with Visual Basic". It covers modules on functions and procedures, including passing arguments by value and reference, arrays, user-defined data types, and using dialog boxes. It provides examples of creating and calling both functions and sub procedures in Visual Basic, and passing arguments to procedures.
The document discusses structures and unions in C programming. It defines a structure as a user-defined data type that allows storing heterogeneous data under a single name. Structures contain members that can be accessed using the dot operator. Arrays of structures allow storing multiple records of the same type. Structures can be nested by defining a structure member within another structure. Unions allow storing different types of data in the same memory location, but only one member can be accessed at a time. Examples are provided to demonstrate defining, declaring, and accessing structure and union variables as well as nested structures.
Functions can take parameters which are names listed in the function's definition. Parameters allow functions to accept arguments when called, and those arguments can then be used inside the function. For example, a function called sayHello is defined to take one parameter called name, and when called with the argument "Dan", it outputs an alert of "Hi, Dan".
This document provides an overview of SQL commands and concepts. It discusses:
1) SPUFI and how it allows direct SQL input in TSO.
2) SQL commands including DDL, DML, TCL, DCL, JOINs, VIEWs, CURSORs, TRIGGERs, FUNCTIONS, and PROCEDUREs.
3) Examples are provided for many of the commands to demonstrate their usage.
This presentation focus on the basic concept of pointers. so that students can easily understand. it also contains basic operations performed by pointer variables and implementation using c language.
Este documento describe varios métodos para resolver sistemas de ecuaciones lineales, incluyendo el método de eliminación de Gauss, el método de Gauss-Jordan, la descomposición LU, la factorización de Cholesky, y métodos iterativos como los métodos de Gauss-Seidel y Jacobi. Explica los pasos involucrados en cada método y provee ejemplos para ilustrar cómo funcionan.
Este documento discute varios factores de motivación en el trabajo, incluyendo teorías como la jerarquía de necesidades de Maslow y la teoría de los dos factores. También cubre destrezas comunicacionales como usar lenguaje simple y directo, y evitar distracciones. Finalmente, identifica tres causas potenciales de conflicto: intereses opuestos, falta de reglas claras, y falta de disposición para resolver problemas.
Technology Solutions is a privately held business established in 2003 that specializes in telecommunications installation services and construction contracting. They provide a wide range of services including broadband cable installation for homes and businesses as well as infrastructure installation like directional boring and splicing. They are focused on meeting customer needs by valuing their employees and trained staff.
presentation delivered at SMART event
please note this presentation was delivered as speaker support material and is intended for reference by attendees not for use as a stand-alone resource
The document provides a summary of commodity price movements on February 4th for several major commodities including the S&P GSCI Total Return Index, gold, silver, copper, crude oil (WTI and Brent), and natural gas. It lists the opening price, daily price range, weekly, monthly, quarterly, and yearly price ranges as well as a brief description for each commodity. All commodities decreased or remained relatively flat on the day except for gold and silver which increased around 1-2%.
Este documento presenta tres algoritmos secuenciales. El primero pide los datos personales de una persona (nombre, apellido, cédula, profesión) y los imprime. El segundo pide dos números e imprime la suma, resta, multiplicación y división. El tercero calcula el salario de un trabajador en base a sus horas trabajadas y la tarifa por hora, aplicando un aumento del 50% a la tarifa para horas extras.
The document discusses the culture at a new company called Tikoo Culture. It explains that Tikoo wants to build a culture where employees feel valued, respected, heard, and supported. This is because having a positive company culture is important for attracting and retaining top talent. The document outlines some initial efforts Tikoo is taking to define and promote their culture, such as having employees identify words that describe being "Tikool" and implementing rewards programs to recognize employees who demonstrate the company's cultural values.
This document provides an overview of working with dates and times in R. It discusses recognizing date-time objects in R, getting the current date and time, and creating date-time objects using the POSIXct and POSIXlt classes. Methods for converting character and numeric data to date-time objects are presented, along with extracting parts of date-time objects and performing computations. The goal is to introduce the reader to key date and time functionality in base R.
This document discusses customer service and its importance for businesses. It defines excellent customer service as treating customers respectfully, following up on feedback, handling complaints gracefully, understanding customer needs and wants, and exceeding expectations. Good customer service increases purchases, referrals, builds reputation and reduces problems. It also notes that businesses should love customers to gain return and new business, and that customer satisfaction is essential for business success.
Bij test automation hebben we het vaak alleen over het testen van code of functionaliteit. Maar wat hebben we aan test automation als we alsnog uren bezig zijn om de UI op regressie te testen? Bestaande tools werken vaak op pagina niveau en geven daardoor veel false positives. Daarom hebben we zelf een node.js tool ontwikkeld die op compent basis werkt. Ik zal uitleggen hoe deze tool vroeg in het development proces kan helpen om visuele regressie te detecteren.
Emorphis will like to share an initial exploration of a brief study it conducted that will ignite our strategic thinking while developing digital solutions for Internet Of Things.
El documento presenta 8 preguntas sobre los temas de centralismo, descentralización y desarrollo regional en el Perú. Pregunta sobre la diferencia entre centralismo y descentralización, los problemas del centralismo en el país y cómo se ha impulsado la descentralización. También pregunta sobre la situación del sector agrario, el Plan de Desarrollo Regional, aspectos del desarrollo como crecimiento demográfico y tecnológico, e instrumentos para medir el desarrollo de un país como el PBI per cápita.
Este documento proporciona instrucciones sobre cómo desarrollar un proyecto cívico para abordar problemas de la comunidad. Explica que un proyecto cívico implica identificar problemas públicos, diseñar e implementar soluciones y evaluar los resultados. Luego, detalla los pasos para desarrollar un proyecto, incluido darle un nombre relevante y positivo, justificarlo, establecer objetivos medibles y alcanzables, y promover la participación ciudadana.
The document discusses functions in C++. It begins by outlining key topics about functions that will be covered, such as function definitions, standard library functions, and function calls. It then provides details on defining and calling functions, including specifying return types, parameters, function prototypes, scope rules, and passing arguments by value or reference. The document also discusses local and global variables, function errors, and the differences between calling functions by value or reference.
This document provides an outline and overview of functions in C++. It discusses:
- The definition of a function as a block of code that performs a specific task and can be called from other parts of the program.
- The standard library that is included in C++ and provides useful tools like containers, iterators, algorithms and more.
- The parts of a function definition including the return type, name, parameters, and body.
- How to declare functions, call functions by passing arguments, and how arguments are handled.
- Scope rules for local and global variables as they relate to functions.
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docxcarliotwaycave
INFORMATIVE ESSAY
The purpose of the Informative Essay assignment is to choose a job or task that you know how to do and then write a minimum of 2 full pages, maximum of 3 full pages, Informative Essay teaching the reader how to do that job or task. You will follow the organization techniques explained in Unit 6.
Here are the details:
1. Read the Lecture Notes in Unit 6. You may also find the information in Chapter 10.5 in our text on Process Analysis helpful. The lecture notes will really be the most important to read in writing this assignment. However, here is a link to that chapter that you may look at in addition to the lecture notes:
https://open.lib.umn.edu/writingforsuccess/chapter/10-5-process-analysis/ (Links to an external site.)
2. Choose your topic, that is, the job or task you want to teach. As the notes explain, this should be a job or task that you already know how to do, and it should be something you can do well. At this point, think about your audience (reader). Will your reader need any knowledge or experience to do this job or task, or will you write these instructions for a general reader where no experience is required to perform the job?
3. Plan your outline to organize this essay. Unit 6 notes offer advice on this organization process. Be sure to include an introductory paragraph that has the four main points presented in the lecture notes.
4. Write the essay. It will need to be at least 2 FULL pages long, maximum of 3 full pages long. You will use the MLA formatting that you used in previous essays from Units 3, 4, and 5.
5. Be sure to include a title for your essay.
6. After writing the essay, be sure to take time to read it several times for revision and editing. It would be helpful to have at least one other person proofread it as well before submitting the assignment.
Quiz2
# comments start with #
# to quit q()
# two steps to install any library
#install.packages("rattle")
#library(rattle)
setwd("D:/AJITH/CUMBERLANDS/Ph.D/SEMESTER 3/Data Science & Big Data Analy (ITS-836-51)/RStudio/Week2")
getwd()
x <- 3 # x is a vector of length 1
print(x)
v1 <- c(2,4,6,8,10)
print(v1)
print(v1[3])
v <- c(1:10) #creates a vector of 10 elements numbered 1 through 10. More complicated data
print(v)
print(v[6])
# Import test data
test<-read.csv("CVEs.csv")
test1<-read.csv("CVEs.csv", sep=",")
test2<-read.table("CVEs.csv", sep=",")
write.csv(test2, file="out.csv")
# Write CSV in R
write.table(test1, file = "out1.csv",row.names=TRUE, na="",col.names=TRUE, sep=",")
head(test)
tail(test)
summary(test)
head <- head(test)
tail <- tail(test)
cor(test$X, test$index)
sd(test$index)
var(test$index)
plot(test$index)
hist(test$index)
str(test$index)
quit()
Quiz3
setwd("C:/Users/ialsmadi/Desktop/University_of_Cumberlands/Lectures/Week2/RScripts")
getwd()
# Import test data
data<-read.csv("yearly_sales.csv")
#A 5-number summary is a set of 5 descriptive statistics for summarizing a continuous univariate data set.
#It consists o ...
Chapter Functions for grade 12 computer ScienceKrithikaTM
1. A function is a block of code that performs a specific task and can be called anywhere in a program. Functions make code reusable, improve modularity, and make programs easier to understand.
2. There are three main types of functions: built-in functions, functions defined in modules, and user-defined functions. Built-in functions are pre-defined and always available, module functions require importing, and user-defined functions are created by programmers.
3. Functions improve code organization and readability by separating code into logical, modular units. Functions can take parameters, return values, and be called from other parts of a program or other functions. This allows for code reuse and modular programming.
This document discusses writing your own functions in Python. It begins by explaining that functions allow you to make code reusable and simplify programs. Functions take arguments, perform operations, and can return values. The document then provides examples of defining, calling, and returning values from functions. It highlights important aspects of functions like arguments, return statements, and scope.
The document discusses procedural abstraction and functions that return values in programming. It covers topics like top-down design, predefined functions, programmer-defined functions, procedural abstraction, local variables, and overloading function names. Some key points include breaking problems into smaller subtasks using top-down design, how predefined and programmer-defined functions work, the use of return values, and how procedural abstraction hides implementation details through a "black box" approach.
This document provides an introduction to data analysis and graphics in R. It covers vectors and assignment, data types including logical, integer, numeric, character, factor, complex and raw. It also discusses data structures such as atomic vectors, matrices, arrays and lists. Finally, it discusses importing data into R from files such as .RData files, text files using read.table(), CSV files and Excel files.
This document provides an outline for a course on quantitative data analysis and graphics in R. The course will cover planning a data analysis, basics of data analysis, testing for normality, choosing appropriate statistical tests, hypothesis testing, confidence intervals, and statistical significance tests both parametric and non-parametric. It will also cover the differences between hypothesis testing and confidence intervals.
This document provides an introduction and overview of graphics and plotting in R. It discusses high level and low level plotting functions, interacting with graphics, and modifying plots. It also covers plotting different variable types including dichotomous, categorical, ordinal, and continuous variables. Examples are provided for various plot types including histograms, bar plots, dot plots, boxplots, and more.
This document provides an introduction and overview of summarizing data in R. It discusses numerical summaries for different variable types including discrete, continuous, dichotomous, categorical, and ordinal variables. Measures of central tendency like mean, median and mode are covered as well as measures of dispersion. Skewness and kurtosis are also discussed. Examples of calculating these summaries for sample datasets are provided.
This document provides an overview of data entry, management, and manipulation in R. It discusses how to create datasets using various functions like c(), matrix(), data.frame(), and list(). It also covers understanding dataset properties, importing data, creating new variables, and subsetting datasets. Useful functions for working with datasets include mode(), length(), dim(), names(), and attributes(). The document shows examples of entering data using these different methods.
R is a free and open-source programming language and software environment for statistical analysis and graphics. RStudio is a popular integrated development environment (IDE) for R that provides a convenient graphical user interface. This document introduces R and RStudio, covering how to install them, their basic layout and features, and how to get help when working with R. Key functions and concepts discussed include loading and installing packages, working directories, and calling functions.
This document introduces level three of a data analysis tutorial series, which focuses on statistics fundamentals. The level aims to provide a good statistics foundation by covering descriptive statistics, exploratory data analysis, inferential statistics, categorical analysis, time series analysis, and survival analysis. Students will learn how to describe and make inferences from data, and the reasoning behind statistical calculations and assumptions to enable sound interpretation of results.
This document provides an introduction to version control systems using Git and GitHub. It begins with an overview of why version control is important and the evolution of version control systems from local to centralized to distributed. It then discusses installing and setting up Git, initializing and tracking files in a Git repository, committing changes, and ignoring files that should not be tracked via a .gitignore file. The goal is for students to understand the basics of Git and GitHub and be able to version control files and collaborate on projects.
A needs analysis involves comparing current conditions to desired goals to understand performance problems. It can be extensive, using large sample sizes for general understanding, or intensive, using smaller samples for in-depth cause-and-effect analysis. Performing a needs analysis involves gap analysis, identifying priorities, outlining a methodology, gathering and analyzing both quantitative and qualitative data, presenting findings, and making conclusions and recommendations. An example needs assessment addressed gender-based violence in schools in Africa through stakeholder interviews, performances, photo voices, drawings, and documentaries to develop an action plan.
This document discusses result-based monitoring and evaluation (M&E). It defines monitoring as the systematic collection of data on indicators, and evaluation as the objective assessment of a project or program's design, implementation and results. The purpose of M&E is to assess progress, determine relevance and fulfillment of objectives, and enhance transparency and accountability. Key aspects of result-based M&E covered include logical frameworks, methods/tools like rapid appraisal and impact evaluation, and essential actions to build an effective result-based M&E system like formulating goals and indicators to measure outcomes.
This document provides an introduction to regular expressions (regex) in R. It discusses literal regex which match text exactly, and metacharacters which have special meanings like ., *, ?, etc. It also covers character classes [ ], anchors ^ and $, quantifiers like ?, *, +, {}, alternations |, and capturing groups () in regex. The document uses examples of matching file names and dates to illustrate regex patterns and their uses in text matching and replacement.
This document provides instructions for a case study on web scraping Olympics data from Wikipedia pages using R. It discusses importing the raw HTML data from the URLs using readLines(), then exploring the structure and content of the imported data. The document emphasizes using base R functions instead of packages for this task. It then provides an overview of HTML to help understand how to locate and extract the desired data tables from the raw HTML.
This document describes several web scraping functions:
1. A web scraper function that extracts data from an HTML document as a character object based on CSS selectors.
2. A function to check if an object is a valid HTML element.
3. A tag counter function that counts the number of tags in a string.
4. Closing tag locator functions that find the closing tags for given opening tags.
5. A content extractor function that extracts HTML elements based on tag positions and can remove tags or construct a data frame.
6. A table constructor function that creates a data frame from an HTML table.
7. A content remover function that removes unwanted content from extractor
This document provides guidance on solving coding problems in R. It discusses identifying and defining problems, and where and how to get help. For problems where the necessary functions are unknown, it recommends gaining foundational R skills through tutorials and practice. For known functions producing errors, warnings or unexpected output, it demonstrates defining the specific problem and potential causes. Sources of help discussed include R's internal documentation, manuals, FAQs, and external resources like web searches and mailing lists. The document also provides an example of solving a statistical mode problem in R.
Plot() is the main plotting function in base R. It is a generic function that dispatches different methods depending on the class of the first argument. When called, plot() follows 8 steps: 1) Open a new plotting window, 2) Set the plotting coordinates, 3) Evaluate pre-plot expressions, 4) Make the actual plot, 5) Evaluate post-plot expressions, 6) Add axes, 7) Add a frame, and 8) Add annotations. The class of the first argument determines which plotting method is used, and additional arguments can customize the plot output.
This document discusses indexing and manipulating data objects in R. It covers indexing one-dimensional objects like vectors and lists, as well as two-dimensional objects like matrices and data frames. Binary operators for comparisons like equality and inequality are also described. The key topics are:
1) Indexing values in data objects using integers, characters, or logical values and discussing one-dimensional vs multi-dimensional objects.
2) Comparing values within and between vectors using binary operators like equality ("==") and inequality ("!="). These operate element-wise on vectors.
3) Checking conditions on data using functions like "all()", "any()", and "which()" to subset objects based on logical criteria.
This document discusses key concepts related to files in R including file names, formats, paths, encodings, and types. It describes text files as human-readable files organized in lines with different extensions for different programs. Binary files contain machine-readable 1s and 0s. Paths locate files in a directory hierarchy using components like parent directories denoted by "..". Common encodings include ASCII for English and UTF-8 for multiple languages. R supports text, binary, and delimited files like CSVs that separate values with commas.
This document discusses importing and exporting data in R. It covers importing data from local files, networks, and databases using both the graphical user interface (GUI) and command line. The key aspects to consider when importing data are the encoding, headers, row names, separators, decimals, quotations, comments, and missing values. Delimited files like CSVs can be imported using read.table() and its wrapper functions, while other file types require packages like foreign and haven. Data can also be exported from R using base functions or packages. The document provides examples of importing delimited text files from a local directory and webpage.
This document discusses R data types and objects. It covers the basic data types in R: logical, integer, real/double, string/character, complex, and raw. The most common data structures are vectors, matrices, arrays, data frames, and lists. Vectors can be atomic, containing one data type, or generic lists, containing multiple data types. The document demonstrates how to create vectors using the c() function or colon operator, and how to name vectors by assigning them to an object. It also discusses the basic properties of vectors like their type, length, dimensions, and classes.
1. Session Two - Making Function Calls
By Hellen Gakuruh
May 21, 2016
Table of Contents
Session Goal................................................................................................................................................................2
What we shall cover ...............................................................................................................................................2
Prerequisite................................................................................................................................................................2
R Functions.................................................................................................................................................................2
Making Function Calls ...........................................................................................................................................3
Function's composition....................................................................................................................................3
A functions name ................................................................................................................................................3
Arguments..............................................................................................................................................................4
Named and Unnamed Argument............................................................................................................4
Position matching for named and unnamed arguments.............................................................5
Default values for arguments...................................................................................................................6
Gauge yourself...........................................................................................................................................................8
2. 2
Session Goal
The main goal of this session is to equip you with the necessary skills to make function calls
in R.
What we shall cover
By the end of this session you should:
• Be conversant with the term function and function call
• Know what constitutes a function and a function call
• Be conversant with arguments
• Distinguish between named and unnamed arguments
• Know how R positions arguments in a call
• Be able to know and change default values
• Have an understanding of what top and low level functions are
• Know what is meant by anonymous functions
Prerequisite
To appreciate this session,
• you must have R and RStudio installed and running
• know how to use the console
• be conversant with RStudio panes like console, help and packages
R Functions
A function is a command you give to a computer program; basically an action you what
performed like getting the sum/total, mean or determine existence of a file in your
computer. There is virtually nothing that can happen in R without the use of a function, for
example, if you want to get data into R, or clean it (data manipulation and transformation),
or analyze it, or even export its output, you must use a function.
Presence of parenthesis “( )” like sum( ), mean( ) or file.exist( ) indicated a function and
when it is used, it is referred to as making a function call.
Before we discuss function calls, let's note the two types of functions in R; these are in-built
functions like sum, mean as well as file.exist and those you develop (also known as user
defined functions). In this session we will discuss in-built functions that come with base R
in form of (default) packages and those available from add-on packages. User defined
functions will be covered in level 2.
3. 3
Making Function Calls
Function's composition
First thing you need to know is the composition of function. A function in R is composed of
a name, arguments/parameters, and Body.
Function composition
A function begins with its name followed by parenthesis and curly braces (body). To make
a function call you need a function's name and it's parenthesis ( ), for example mean( ) (the
body or what is in curly braces is not necessary to make a call but it will give you insight as
to how the function works).
A functions name
Most functions in R are named after the actions they should perform, for example the two
average functions mean and median. Others include sum, exit, ncol (number of columns),
nrow (number of rows) e.t.c.
However, there are numerous other functions that might not follow this kind of logic, for
example, you might expect a function called "mode" to get the most frequently occurring
observation (the third measure of central tendency), however, this is not the case as mode
in R has a totally different meaning. It gives the internal type of an object (we shall discuss
this in the fourth session)
Key point to note here is that, knowing a function's names comes with practice, reading R
manuals (help.start()) and online tutorials/discussions/Q and A.
One final tip on function names, there are unnamed functions usually included in other
functions, these are referred to as anonymous functions.
For example, the function within the sapply function (with one argument x) is an
anonymous function.
a <- list(1:10, 11:20, 21:30, 31:40, 41:50)
b <- list(round(rnorm(10), 1), round(rnorm(10), 1), round(rnorm(10), 1),
round(rnorm(10), 1), round(rnorm(10), 1))
4. 4
# Anonymous function
sapply(1:5, function(x) a[[x]] + b[[x]])
## [,1] [,2] [,3] [,4] [,5]
## [1,] 0.9 9.7 21.9 31.5 41.1
## [2,] 2.3 11.7 21.5 29.9 42.9
## [3,] 2.1 14.6 22.5 34.0 42.2
## [4,] 2.9 14.2 23.0 32.7 43.6
## [5,] 6.2 14.3 25.2 35.7 45.3
## [6,] 6.3 14.4 26.0 36.4 45.4
## [7,] 6.6 17.8 26.4 36.7 49.1
## [8,] 6.5 18.5 28.3 37.5 46.1
## [9,] 9.8 19.3 29.7 38.7 48.5
## [10,] 11.4 19.0 28.6 41.0 50.2
Arguments
Within the parenthesis of a function are arguments or parameters. These arguments
specify how a function will work or how a command will be carried out. It's important to
know a function's arguments as they have implications on the output you receive.
Sometimes this can result is an error meaning nothing is produced or a warning.
To know a function's argument, you need to read its documentation which can be accessed
with the function help() or preceding the function's name with a questions mark. For
example, get documentation for the mean function by typing either help(mean) or ?mean
on the console. The documentation should appear on the help tab located on the right
lower pane.
From this documentation (at the top), you will notice the name of the function requested,
and in curly braces the package to which the documentation comes from i.e. base package.
The package name is given to identify location of a function. This stems from the fact that
other non-base R packages can have similar names as those in base R.
Right below is the title of the documentation, in this case the arithmetic mean; R's default
mean. A short description of the function is also given followed by a section on the
function's usage. This "Usage" section shows how the function is called in terms of its name
and arguments.
But before we discuss this section, there are some critical issues we need to discuss first,
these include naming of arguments, their order in a call and default values.
Named and Unnamed Argument
Going back to the mean documentation and specifically the usage section, we see two ways
of calling the mean function, that is R's mean(x, ...) and S3's mean(x, trim = 0, na.rm =
FALSE, ...). Both of these work the same, the minor difference can be understood by
reading up on Object Oriented Programming in R.
Looking at the second function, the S3 method, there are four arguments, these are x, trim,
na.rm, and .... These are the names of the arguments and to make a call you need to give
values to these arguments.
5. 5
You can make a function call with only values specified or with named arguments. To
understand what this means, let's first get to know what the arguments for the mean
function are and their expected values: The section called Arguments will guide us on this.
From this section we can see that x is an object (object can be described as any entity in R)
and the expectation is that it should either be a numeric/logical vector (variable), date,
date-time or time interval objects: Anything other than this will raise a warning. Trim is a
fraction of observations to remove from computation (suitable for dealing with skewed
data or outliers ), the expectation is that it should be a value between 0 and 0.5. In R, NA
means missing data and therefore na.rm is an argument indicating how missing data
should be handled, the expected values are either true or false (remove or don't remove).
For now let's leave the ... argument as it requires a bit of knowledge in methods.
Now that we know what x, trim and na.rm mean, lets look at how to make function calls
with both named and unnamed argument.
# To call the mean function, you can name the arguments.
mean(x = c(2, 5, 9, 3), trim = 0.5, na.rm = TRUE)
## [1] 4
# Or call with unnamed arguments
mean(c(2, 5, 9, 3), 0.5, TRUE)
## [1] 4
Position matching for named and unnamed arguments
If you call a function with named arguments, then the position of the arguments do not
matter.
# Matching position of the arguments.
mean(x = c(2, 5, 9, 3), trim = 0.5, na.rm = TRUE)
## [1] 4
# Mixing the order of arguments
mean(trim = 0.5, x = c(2, 5, 9, 3), na.rm = TRUE)
## [1] 4
But if you have unnamed arguments then you need to give the values of arguments
according to their order as R will match each value with argument in that position.
# Mixing order for unnamed argument
mean(TRUE, 0.5, c(2, 5, 9, 3))
## [1] TRUE
## Warning message:
## In if (na.rm) x <- x[!is.na(x)] :
## the condition has length > 1 and only the first element will be used
R has given us a result of TRUE, not exactly what we expected, and in addition it has given
us a warning indicating a problem with the call. What happened is that R marched TRUE to
the X argument, 0.5 to the trim argument and c(2, 5, 9, 3) to the na.rm argument. Since the
6. 6
expected values for X include logical values, putting true where x should be is okay by R,
however, when you put more than one value where one value (true/false) is expected, then
you will get a warning message.
If you have named and unnamed arguments the rule of the thumb is to name subsequent
arguments, otherwise R will match the values with the position of the other arguments.
# Naming the second and subsequent argument
mean(c(2, 5, 9, 3), trim = 0.5, na.rm = TRUE)
## [1] 4
# Naming only the second argument
mean(c(2, 5, 9, 3), trim = 0.5, TRUE)
## [1] 4
The second call did not raise a warning as the last value was matched to the correct
argument but this might not be the case in other situations.
Now let's look at default values.
Default values for arguments
Arguments can have default values which are used if a call is made without the argument.
For example, the mean function has two arguments with default values, these are trim and
na.rm. This means a call can be made with only the value of x, but if x is missing, then you
will get an error.
# Calling the mean with only x
mean(x = c(2, 5, 9, 3))
## [1] 4.75
# You call with default values but that's just unnecessary
mean(x = c(2, 5, 9, 3), trim = 0, na.rm = FALSE)
## [1] 4.75
# Making a function call without the x value
mean(trim = 0.5, na.rm = TRUE)
##Error in mean.default(trim = 0.5, na.rm = TRUE) :
## argument "x" is missing, with no default
If a default value is not what you want, you can add the argument specifying the value you
want. For example, since the above data set has an extreme value (9), we can use the trim
function to make the average reasonable.
# Trimming 0.5 (50%) from the dataset or 0.25 (25%) from beginning and the
end of the dataset instead of the default 0
mean(c(2, 5, 9, 3), trim = .5)
## [1] 4
# Compare with the median
7. 7
median(c(2, 5, 9, 3))
## [1] 4
If we had a data set with missing values, then we need to tell R to make the computation
without the missing values otherwise it will result in NA
# Taking the mean of a dataset with NA when na.rm is false (default)
mean(c(2, 5, 9, 3, NA), trim = .5)
## [1] NA
# Taking the mean of a dataset with NA when na.rm true
mean(c(2, 5, 9, 3, NA), trim = .5, na.rm = TRUE)
## [1] 4
The mean has a short and straightforward list of arguments, but others might have a
number of arguments. For example, pull up the help documentation for importing data;
that is, help(read.table). This function has more than 20 listed arguments. But if you take
a keen look at most of the arguments, you will notice that most of the arguments have
default value. It is of great interest to you to read through the descriptions of all the
arguments and confirm that the defaults are okay, this is usually a source of many
challenges in function calls and expected outputs.
In addition to checking the help documentations, you can use the function args() to see the
list of arguments for a specified function.
# Mean arguments
args(mean)
## function (x, ...)
## NULL
# Read.table arguments
args(read.table)
## function (file, header = FALSE, sep = "", quote = ""'", dec = ".",
## numerals = c("allow.loss", "warn.loss", "no.loss"), row.names,
## col.names, as.is = !stringsAsFactors, na.strings = "NA",
## colClasses = NA, nrows = -1, skip = 0, check.names = TRUE,
## fill = !blank.lines.skip, strip.white = FALSE, blank.lines.skip =
TRUE,
## comment.char = "#", allowEscapes = FALSE, flush = FALSE,
## stringsAsFactors = default.stringsAsFactors(), fileEncoding = "",
## encoding = "unknown", text, skipNul = FALSE)
## NULL
It is also useful to note that there are functions called top level and those that are called
low level. Top level functions are functions that we mostly use to perform an action, while
low level functions are called by the top level functions. For example, when computing the
mean, you would call on the mean() function which in-turn calls the sum and length
function to get you the mean. So in this case the mean is a top level function while sum()
and length() are the low level functions or helper functions.
8. 8
Later in level two as we learn user defined functions, we shall discuss functions in terms
of argument, body and environment.
Gauge yourself
1. What are functions?
2. How can you tell an object is a function?
3. What is meant by a function call?
4. What constitutes a function call?
5. What are arguments?
6. Distinguish between named and unnamed arguments
7. What do you expect would happen if I made a function call with all the necessary
argument but only the second argument is named and distort the position of the other
arguments?
You are ready for the third session if you know these
1. Functions are commands issued for an action to be performed
2. In R an object name followed by parenthesis indicates a function
3. A function call occurs when a function is used or run
4. A function call constitutes a name of a function and it's arguments
5. Arguments give details or input for function execution
6. A function call with arguments and their values are referred to as named arguments
while a call with values only is known as unnamed arguments.
7. Since all the arguments are provided, then you will not receive an error, however, due
to distortion of position, if the value given does not meet the expected value, a warning
will be issued and output generated will be questionable.
Note
This write-up has used non programming definition in as much as possible with the intent
of being useful to non-programmers and imparting concepts and skills necessary for
analysis.