Professional Documents
Culture Documents
PREV NEXT
⏮ ⏭
APPENDIX D: INTRODUCTION TO SAS REFERENCES
🔎
APPENDIX E
pricing options.
2. Provide a reference point for individuals, instititutions or
commercial enterprises that want to support or interact with
the R development community.
Temp vp
273 4.6
283 9.2
293 17.5
303 31.8
313 55.3
323 92.5
333 149.4
343 233.7
353 355.1
temp <- c(273, 283, 293, 303, 313, 323, 333, 343, 353, 363, 373)
vp <- c(4.6, 9.2, 17.5, 31.8, 55.3, 92.5, 149.4, 233.7, 355.1, 52
To check your data entry, you can use the print() function. In our case,
print(temp)
print(vp)
> print(temp)
[1] 273 283 293 303 313 323 333 343 353 363 373
> print(vp)
[1] ?4.6 ?9.2 ?17.5 ?31.8 ?55.3 ?92.5 149.4 233.7 355.1 525.8 7
For small data sets, the brute force approach works well. For larger data sets, we
recommend using the read.table() function. You can create a text file with the
data in columns. Generally, the first row is a “header” giving the variable names.
The read.table() function works well for this type of file. Let vapor.txt be such a
file for the vapor pressure data. The first step is to change the working directory
for R to the directory that contains the data file. You can do this under the File
box. The following command reads the data file and places the data into the
object vapor.
To check the contents of vapor, we can use the print() function. The resulting
output is:
> print(vapor)
temp vp
1 273 4.6
2 283 9.2
3 293 17.5
4 303 31.8
5 313 55.3
6 323 92.5
7 333 149.4
8 343 233.7
9 353 355.1
10 363 525.8
11 373 760.0
If we read the data from a file, then we cannot refer to the temperatures as temp
even though temp was the name of the column in the original data file; rather, we
must also specify the object that contains it. The following command prints the
temp column of the vapor object.
Find answers on the fly, or master something new. Subscribe today. See
> print(vapor$temp)
[1] 273 283 293 pricing options.
303 313 323 333 343 353 363 373
Basic physical chemistry suggests modeling the natural log of the vapor pressure
as a linear function of the inverse of the temperature. The following commands
create the inverse of the temperatures and then prints them.
The log() function genrates the natural log. The following commands create the
natural log of the vapor pressures and then prints them.
Another useful command for regression analysis is the sqrt() function, which
works exactly like the log() function.
R does generate plots, but it takes a great deal of work to make good looking
plots. The basic plot function is plot(y,x) where y is the object on the y-axis and x
is the object on the y-axis. The following command generates the scatter plot for
the vapor pressure data.
> plot(vapor$vp,vapor$temp)
The write.table() function generates an output data file that is useful for using
other plotting software. The following code appends the inverse temperatures and
the natural logs of the vapor pressures to the original data to form a new object
vapor2 and then creates the output data file vapor_output.txt.
E.4 R Commander
R Commander is an add-on package to R. It also is freely available. It provides
an easy-to-use user interface, much like Minitab and JMP, to the parent R
product. R Commander makes it much more convenient to use R; however, it
Find answers ondoesthe fly, much
not provide or master
flexibility in itssomething new.
analysis. For example, Subscribe today. See
R Commander
does not allow the user to use the externally studentized residual for the residual
pricing options.
plots. R Commander is a good way for users to get familiar with R. Ultimately,
however, we recommend the use of the parent R product.
Find answers on the fly, or master something new. Subscribe today. See
pricing options.