![]() Create a new R script file, and copy this code into it: a a b print(a) where each number is the sum of the previous two numbers. We'll start by using a "while loop" to print out the first few Fibonacci numbers: 0, 1, 1, 2, 3, 5, 8, 13. The expression can be a single R command - or several lines of commands wrapped in curly brackets: for ( variable in sequence ) In R a while takes this form, where variable is the name of your iteration variable, and sequence is a vector or list of values: ![]() Relevant help pages can be found with help("Control") and help("Function"). On the preceding pages we have tried to introduce the basics of the R language - but have managed to avoid anything you might need to actually write your own program: things like if statements, loops, and writing functions. ![]() You probably won't need this information for your assignments ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |