Book Image

Learning Shiny

By : Hernan Resnizky
Book Image

Learning Shiny

By: Hernan Resnizky

Overview of this book

Table of Contents (19 chapters)
Learning Shiny
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Introducing R, RStudio, and Shiny
Index

Object-oriented programming concepts


As in any other object-oriented programming language, a class in R is an abstract definition of an object type with specific attributes associated to it. For instance, for an eventual dog class (which is a general definition of a dog), we could say that it has the color, size, age, and so on attributes.

An object is an instance of a specific class. Continuing with the previous example, we could have a Dog1 object whose attributes can be the following:

  • color: "brown"

  • size: 5.5 inch

  • age: 3 years

In R, the attributes of an object can be accessed by typing attr(object, "attribute"), for instance:

data(iris)
attributes(iris)

In this example, a data frame object (data frame objects will be explained later in this chapter) called iris is loaded, which has the names, row.names, and class attributes (R considers the class of an object an attribute as well). In most cases, many of the values for these attributes in a particular object can be accessed by typing either...