Download presentation
Presentation is loading. Please wait.
Published byBeatrice Dean Modified over 8 years ago
1
ST610-002 Intro to R programming Big picture language features -- just a brief description here -- more later:
2
Interpretive R translates symbols (e.g. x, 2.53, *, qr) into numbers, variables, and other expressions which are evaluated immediately (almost)
3
Object-oriented "everything is an object" Well, that really doesn't say anything. But as I see it, if a function takes a certain kind of object -- as long as R can recognize it or force into something it can recognize, then a function will work -- and produce another object, for another function or expression to work with. Variables, constants, and functions are all objects.
4
Coercion R will instinctively try to make sense of any expression that you give it, even if to you it is nonsense. So this can be very dangerous, as R will proceed many times when you would prefer that it would stop processing for syntax errors.
5
Recycling When R is trying to coerce something to work, and it needs more numbers, it will instinctively reuse the numbers that it has. For example, if you try to add a constant to a vector, R will really take the constant and make a vector of the same length as the other with it, by repeating the single number that it has. While very powerful, this can also be dangerous.
6
Lexical Scoping The real power of R is in its functions, and R creates a new working environment with each instance of a function. Variables are referenced (scoping) according its nested environment structure.
7
Natural and unnatural looping R is designed to do vector/matrix calculations and works best when calculations are coded to that end. R does have a loop feature (for loop) which can be competitive in speed to its natural looping, but more often is slow and inefficient.
8
Some Details gui vs batch and directory reference source("infile.name") sink("outfile.name") and sink() to discontinue.RData and.Rhistory help(command) q() to stop # begins a comment that continues to the end of the record
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.