R 4 Quick Syntax Reference by Margot Tollefson
Author:Margot Tollefson
Language: eng
Format: epub
ISBN: 9781484279243
Publisher: Apress
source(
"ch9.dg2.txt"
)
cat(
"function ( x = 1:3 )
print( x )",
file="ch9.dg3.txt"
)
system(
"cat ch9.dg3.txt"
)
ch9.dg3=dget(
"ch9.dg3.txt"
)
ch9.dg3
ch9.dg3()
ch9.sc3 = source(
"ch9.dg3.txt"
)
ch9.sc3
ch9.sc3$value()
cat(
"function( x=4 )
print( round( rnorm( x ), 2 ) )",
file="ch9.dg4.txt"
)
system(
"cat ch9.dg4.txt"
+ )
dget(
"ch9.dg4.txt",
keep.source=TRUE
)
dget(
"ch9.dg4.txt"
)
Note that in the first example, the text is entered at the console. In the first part of the example, the text is parsed and evaluated. In the second part, a function is entered and assigned to an object, so the text is parsed and evaluated, but the function is not run.
In the second example, dget() and source() read from the ch9.dg2.txt file on the computer, which is parsed and evaluated. Numbers are returned, since the text in the file is not a function definition.
In the third example, a function that is stored in the ch9.dg3.txt file on the computer is first read by dget() and saved to the ch9.dg3 object. Then ch9.dg3() is output and run. A vector of numbers is returned when the ch9.dg3() is run. Next, the file is read by source(). The result (which is a list) is saved to the ch9.sc3 object. The list is output, and the value element of the list (which contains the function) is run. The same vector of numbers is returned as with dget(). Note that dget() and source() give different results when the object that is read is a function definition.
In the fourth example, a function in a file on the computer is read with keep.source equal to TRUE, then with keep.source equal to FALSE (the default value). The first call returns the function as written. The second call simplifies the format of the code.
For more information about dget() and source(), use the RStudio Help tab or enter ?dget and ?source, respectively, at the R prompt.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Ada | Ajax |
Assembly Language Programming | Borland Delphi |
C & C++ | C# |
CSS | Compiler Design |
Compilers | DHTML |
Debugging | Delphi |
Fortran | Java |
Lisp | Perl |
Prolog | Python |
RPG | Ruby |
Swift | Visual Basic |
XHTML | XML |
XSL |
Hello! Python by Anthony Briggs(9916)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9796)
The Mikado Method by Ola Ellnestam Daniel Brolund(9779)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8300)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7781)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Windows APT Warfare by Sheng-Hao Ma(6849)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(6584)
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition by Marcos Romero & Brenden Sewell(6454)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6417)
Kotlin in Action by Dmitry Jemerov(5065)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4317)
Functional Programming in JavaScript by Mantyla Dan(4038)
Solidity Programming Essentials by Ritesh Modi(4009)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3801)
Unity 3D Game Development by Anthony Davis & Travis Baptiste & Russell Craig & Ryan Stunkel(3745)
The Ultimate iOS Interview Playbook by Avi Tsadok(3719)
