Skip to main content

How to Use a Script or Function

  • Chapter
  • First Online:
R Quick Syntax Reference
  • 1349 Accesses

Abstract

While scripts are just listings of code stored outside of R, functions are objects of mode function and are stored in the workspace. Most functions require specific kinds of arguments, which must be input into the function correctly. For example, if a function calls for a matrix and a data.frame is input, the function will return an error. Since external tables are often read into the R workspace as data.frames, using a data.frame for a matrix is quite a common error. This chapter covers calling a function, using arguments in a function, and accessing the output of a function, as well as an example of using a script to do a simple mining of Twitter.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 29.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Margot Tollefson

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Tollefson, M. (2019). How to Use a Script or Function. In: R Quick Syntax Reference. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-4405-0_8

Download citation

Publish with us

Policies and ethics