12.07.2015 Views

R dummies

R dummies

R dummies

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Creating and assigning named vectorsYou use the assignment operator ( month.days names(month.days) month.daysJanuary February March April31 28 31 30May June July August31 30 31 31September October November December30 31 30 31Now you can use this vector to find the names of the months with 31 days:> names(month.days[month.days==31])[1] “January” “March” “May”[4] “July” “August” “October”[7] “December”This technique works because you subset month.days to return only thosevalues for which month.days equals 31, and then you retrieve the names of theresulting vector.The double equal sign (==) indicates a test for equality (see Chapter 4).Make sure not to use the single equal sign (=) for equality testing. Not only willa single equal sign not work, but it can have strange side effects because Rinterprets a single equal sign as an assignment. In other words, the operator =in many cases is the same as

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!