Last Thesis Class of the Semester


    I spent about half of the class editing my midterm research paper. It is about eight pages long, and it summarizes my experience so far in this research. I am proud of my educational process so far. Now, I need to make progress on the coding. Tonight, I am going to begin the bare bones of this function, so that when I get the data sets, I won't start completely from scratch.


   Then, I learned how to build a class in R. In an S3 (informal) class, the class definition is coded inside of a method. The class holds the data entries from in input. I am a little confused about the syntax of the class definition, but I am going to look more into it tonight. It is a lot different from Java. S4 classes are more formal classes. You use the setClass() function to construct the instance variables and important functions. I realize that classes in R have a different purpose than in Java: you build a class so that you can learn more about your output. It is not necessary for coding purposes. I can use the class to store information about my data, such as equipment serial numbers, mileage, cost of parts, etc.

Methods Related to Classes:

" setClass:
Define Class to be an S-style class. The effect is to create an object, of class "classRepEnvironment", and store this (hidden) in the specified environment or database. Objects can be created from the class (e.g., by calling new), manipulated (e.g., by accessing the object's slots), and methods may be defined including the class name in the signature (see setMethod).
removeClass:
Remove the definition of this class, from the environment where if this argument is supplied; if not, removeClass will search for a definition, starting in the top-level environment of the call to removeClass, and remove the (first) definition found.
isClass:
Is this the name of a formally defined class? (Argument formal is for compatibility and is ignored.)
getClasses:
The names of all the classes formally defined on where. If called with no argument, all the classes visible from the calling function (if called from the top-level, all the classes in any of the environments on the search list). The inherits argument can be used to search a particular environment and all its parents, but usually the default setting is what you want.
findClass:
The list of environments or positions on the search list in which a class definition of Class is found. If where is supplied, this is an environment (or name space) from which the search takes place; otherwise the top-level environment of the caller is used. If unique is supplied as a character string, findClass returns a single environment or position. By default, it always returns a list. The calling function should select, say, the first element as a position or environment for functions such as get.
If unique is supplied as a character string, findClass will warn if there is more than one definition visible (using the string to identify the purpose of the call), and will generate an error if no definition can be found.
resetClass:
Reset the internal definition of a class. Causes the complete definition of the class to be re-computed, from the representation and superclasses specified in the original call to setClass.
This function is called when aspects of the class definition are changed. You would need to call it explicitly if you changed the definition of a class that this class extends (but doing that in the middle of a session is living dangerously, since it may invalidate existing objects).
sealClass:
Seal the current definition of the specified class, to prevent further changes. It is possible to seal a class in the call to setClass, but sometimes further changes have to be made (e.g., by calls to setIs). If so, call sealClass after all the relevant changes have been made. "




Sources Used:

http://www.cyclismo.org/tutorial/R/s3Classes.html

http://astrostatistics.psu.edu/su07/R/library/methods/html/setClass.html

Comments