Vectors and DataFrames

Slides:



Advertisements
Similar presentations
CS 116 Tutorial 6 Strings, Raw Input, Lists. 1. Write a function convert_format that consumes nothing, but takes keyboard input. The program prompts "Enter.
Advertisements

What is shape function ? shape function is a function that will give the displacements inside an element if its displacement at all the node locations.
Objective: Dealing with data in C++ Agenda: Notes Essay Help.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
Module 6 Matrices & Applications Chapter 26 Matrices and Applications I.
® Microsoft Office 2010 Excel Tutorial 1: Getting Started with Excel.
Baburao Kamble (Ph.D) University of Nebraska-Lincoln Data Analysis Using R Week2: Data Structure, Types and Manipulation in R.
Correlation and Covariance. Overview Continuous Categorical Histogram Scatter Boxplot Predictor Variable (X-Axis) Height Outcome, Dependent Variable (Y-Axis)
Correlation and Covariance
Introduction to to R Emily Kalah Gade University of Washington Credit to Kristin Siebel for development of much of this PowerPoint.
 For Loops › for (variable set; condition; incremental or decrement){ // loop beginning › } // loop end  While loops › while (condition) { // beginning.
Data Objects in R Vector1 dimensionAll elements have the same data types Data types: numeric, character logic, factor Matrix2 dimensions Array2 or more.
EPIB 698C Lecture 2 Notes Instructor: Raul Cruz 2/14/11 1.
Chapter 5: Data Types (2013) Revision Candidates should be able to know: Identify different data types? Key terms: File, record, field and key field Database.
R-Studio and Revolution Analytics have built additional functionality on top of base R.
Introduction to R and Statistics Thomas INGICCO G. Courbet, Le désespéré (Autoportrait) G. Courbet, The desperate man (Self-portrait)
R Programming Yang, Yufei. Normal distribution.
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Using Text Files in Excel File I/O Methods. Working With Text Files A file can be accessed in any of three ways: –Sequential access: By far the most common.

School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Matlab Basic. MATLAB Product Family 2 3 Entering & Quitting MATLAB To enter MATLAB double click on the MATLAB icon. To Leave MATLAB Simply type quit.
Table formats ArcGIS reads table in many formats: dBase format (shapefile) INFO format (workstation ArcInfo) Geodatabase table (MS Access in case of personal.
Introduction to Engineering MATLAB – 4 Arrays Agenda Creating arrays of numbers  Vectors: 1-D Arrays  Arrays: 2-D Arrays Array Addressing Strings & String.
Learn R Toolkit D Kelly O'DayExcel & R WorldsMod 2 - Excel & R Worlds: 1 Module 2 Moving Between Excel & R Worlds Do See & HearRead Learning PowerPoint.
CMPS 1371 Introduction to Computing for Engineers CHARACTER STRINGS.
S-PLUS Lecture 4 Jaeyong Lee Pennsylvania State University.
R objects  All R entities exist as objects  They can all be operated on as data  We will cover:  Vectors  Factors  Lists  Data frames  Tables 
Querying Databases A query is a program that allows us to VIEW the data or operate on the data Several types of queries –Select query –Merge query –Summary.
DATA TYPES, VARIABLES AND CONSTANTS. LEARNING OBJECTIVES  Be able to identify and explain the difference between data and information  Be able to identify,

Data & Graphing vectors data frames importing data contingency tables barplots 18 September 2014 Sherubtse Training.
Texas State Technical College DISCOVER! Conversion Functions “Convert this!”
Actor Heights 1)Create Vectors of Actor Names, Heights, Date of Birth, Gender 2) Combine the 4 Vectors into a DataFrame.
Basics in R part 2. Variable types in R Common variable types: Numeric - numeric value: 3, 5.9, Logical - logical value: TRUE or FALSE (1 or 0)
Lecture 11 Introduction to R and Accessing USGS Data from Web Services Jeffery S. Horsburgh Hydroinformatics Fall 2013 This work was funded by National.
Data Management Data Types R basic 11/11/2013. Data Types 1. Vector 2. Factor 3. Matrix 4. Array 5. List 6. Dataframe.
Vectors and DataFrames. Character Vector: b
DATA TYPES.
Introduction to R user-friendly and absolutely free
IGCSE 4 Cambridge Designing a database table Computer Science
Introduction to SPSS SOCI 301 Lab session.
Variables Variables are used to store data or information.
Downloading and Preparing a StudentVoice File for SPSS
Sections Text Mining Plan Twitter API twitteR package
DATA MANAGEMENT MODULE: Getting Data Into and Out of R
Naomi Altman Department of Statistics (Based on notes by J. Lee)
Advanced Genomics - Bioinformatics Workshop
Uploading and handling databases
Web Programming– UFCFB Lecture 19-20
DATA MANAGEMENT MODULE: Getting Data Into and Out of R
Numerical Descriptives in R
Advanced Data Import & Export Jeff Henrikson
Introduction to Matrices
CSCI N207 Data Analysis Using Spreadsheet
Logical Operations In Matlab.
Statistics 540 Computing in Statistics
Islamic University of Gaza
JavaScript.
MIS2502: Data Analytics Introduction to R and RStudio
R in Action Chapter 4. Basic data management A working example
C# Revision Cards Data types
Kirkwood Center for Continuing Education
Understanding Variables
Creating a dataset in R Instructor: Li, Han
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Data Types and Maths Programming Guides.
Chapter 4 Basic data management Instructor: Li, Han.
Starter Activities GCSE Python.
Database Instructor: Bei Kang.
Presentation transcript:

Vectors and DataFrames

Framework Source: Hadley Wickham Data Structures numeric vector character vector Dataframe: d <- c(1,2,3,4) e <- c("red", "white", "red", NA) f <- c(TRUE,TRUE,TRUE,FALSE) mydata <- data.frame(d,e,f) names(mydata) <- c("ID","Color","Passed") List: w <- list(name="Fred", age=5.3) Numeric Vector: a <- c(1,2,5.3,6,-2,4) Character Vector: b <- c("one","two","three") Matrix: y<-matrix(1:20, nrow=5,ncol=4) Framework Source: Hadley Wickham

Variable Types Numeric: e.g. heights String: e.g. names Dates: “12-03-2013 Factor: e.g. gender Boolean: TRUE, FALSE

Actor Heights Create Vectors of Actor Attributes Names, Heights, Date of Birth, Gender 2) Combine the 4 Vectors into a DataFrame

Creating a Character / String Vector Create a variable (aka object) called ActorNames: Actors <- c("John", "Meryl", "Andre")

Class, Length, Index class(Actors) length(Actors) Actors[2]

Creating a Numeric Vector / Variable Create a variable called h (inches): h <- c(77, 66, 90) Using just one letter for the name to make this quicker to enter.

Creating a Date Variable Create a Character Vector DOB <- c("1930-10-27", "1949-06-22", "1946-05-19" ) Use the as.Date() function: DOB <-as.Date(DOB) Each date has been entered as a text string (in quotations) in the appropriate format (yyyy-mm-dd). By enclosing these data in the as.Date() function, these strings are converted to date objects.  

Creating a Categorical / Factor Variable Create a character vector: g <- c("m", "f", "m") class(g) Use the factor() function to convert to a categorical: g <- factor(g)   https://www.stat.berkeley.edu/classes/s133/factors.html

Create a DataFrame from Vectors Actors.DF <- data.frame(Name=Actor, Height=h, Birthday = DOB, Gender=g) dim(Actors.DF) Actors.DF$Name

Rows and Columns

Array of Rows and Columns 1 2 3 4 Actors.DF[1,] Actors.DF[,2] Actors.DF[3,3] Actors.DF[2:3,] column 2 row 3, column 3 row 1 rows 2,3, all columns mean(Actors.DF[,2])

Write / Create a File write.table(Actors.DF, "ActorData.txt", sep="\t", row.names = TRUE) write.csv(Actors.DF, "ActorData.csv")