Processor pentiumii selecng tuplerow in r we can

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: * FROM chips;! processor | date | transistors | microns | clockspeed | width | mips ------------+------+-------------+---------+------------+-------+------ 8080 | 1974 | 6000 | 6| 2| 8 | 0.64 8088 | 1979 | 29000 | 3| 5| 16 | 0.33 80286 | 1982 | 134000 | 1.5 | 6| 16 | 1 80386 | 1985 | 275000 | 1.5 | 16 | 32 | 5 80486 | 1989 | 1200000 | 1| 25 | 32 | 20 Pentium | 1993 | 3100000 | 0.8 | 60 | 32 | 100 PentiumII | 1997 | 7500000 | 0.35 | 233 | 32 | 300 PentiumIII | 1999 | 9500000 | 0.25 | 450 | 32 | 510 Pentium4 | 2000 | 42000000 | 0.18 | 1500 | 32 | 1700 •  By conven;on, we display SQL statements in upper case. Statements are ended by a semicolon. A>ributes / Variables •  Recall that in R, we can select par;cular variables (columns) by name. chips[ , c(‘mips’, ‘microns’)] •  The order of the variable names determines the order in which they’ll be returned in the resul;ng data frame. •  The corresponding SQL query is SELECT mips, microns FROM chips; SQL Syntax •  Similar to a sentence in English, except that there’s less flexibility in the order of the words. •  Sentence ends with a ; •  Use blanks and “,” and “=“ and () as delimiters •  We will only look at SELECT statements, which begin with the term SELECT Examples of SELECT statements SELECT * FROM chips;! SELECT mips, microns FROM chips;! SELECT * FROM chips ! WHERE processor = ‘Pentium’ OR! processor = ‘PentiumII’;! Selec;ng Tuple/Row In R we can select rows that match a condi;on: chips[chips$processor == ‘Pentium’ |! chips$processor == ‘PentiumII’,]! The corresponding SQL statement is SELECT * FROM chips ! WHERE processor = ‘Pentium’ OR! processor = ‘PentiumII’;! Note: Whitespace can be used freely in SQL statements. We oeen separate lines for clarity. The statement isn’t evaluated un;l the semicolon is entered. •  Aside: In R, it usually doesn’t ma>er whether you use single or double quotes to surround character strings. In SQL, the standard is to use single quotes, so we will do this throughout the notes for bo...
View Full Document

This document was uploaded on 02/16/2014 for the course STATISTICS 3026 at Columbia.

Ask a homework question - tutors are online