The course is part of this learning path
This module looks at more complex data structures, building on what was covered in the intermediate data structures module.
The objectives of this module are to provide you with an understanding of:
- How to construct a factor in R
- How to construct a data frame in R
- How to modify a data frame
- How to subset a data frame
- Data frames automatically factorising data in R
Aimed at all who wish to learn the R programming language.
No prior knowledge of R is assumed.
Delegates should already be familiar with basic programming concepts such as variables, scope, and functions.
Experience of another scripting language such as Python or Perl would be an advantage.
Understanding mathematical concepts will be beneficial.
We welcome all feedback and suggestions - please contact us at firstname.lastname@example.org to let us know what you think.
- If we are making components that are to be re-used, perhaps across several applications and by several different developers, it's useful if it's clear what a component should receive as props. The PropTypes package, which needs to be imported into any component that wants to use proptypes, supplies this functionality. It helps ensure the correct usage of components by clearly defining what data type a prop should be, and can be even more explicit by specifying the shape of an object passed as a prop. You can see in the code, after adding the import, we specify proptypes for each props in this component. This is done by adding a prop types object to the component, and then specifying the name of the prop and the proptype it should be. So for header text, this is a proptype.string. For the object prop, we have specified its shape and you can see that for the function prop, we are able to specify it's prop type as func. Console warnings are produced if the correct type for a prop was not used, as you can see from the first warning on the browser window. Proptypes can also be used to express if a particular prop has to be supplied or not. We can chain the, dot is required to any prop type declaration, like has been done for the unsupplied proptype of any. This has the effect of producing a console warning if the prop is not available and you can see this in the second warning, in the console window. Overall, proptypes can make components easier to read and understand. Some argue that, used correctly, proptypes can negate the need for typescript when writing React applications. If you start your project using create-react-app, the proptypes package is included in the project by default so you don't need to download and install it. However, it will only be bundled into your deployment app if you actually use it. If you didn't use create-react-app to start your project, proptypes is an MPM package that can be easily added. More detailed information on proptypes can be found in the official React documentation. So now you have all the knowledge you need to be able to create a fully static version of a application.
About the Author