You are here:
Vanderbilt Biostatistics Wiki
>
Main Web
>
Seminars
>
RClinic
>
DesiredOutputFn
(10 Nov 2006,
TheresaScott
)
(raw view)
E
dit
A
ttach
---+ A function that returns the desired output from another function Often, you do not want to return all of the default output from a specific function. The following function is just one example of a user-defined function that returns (i.e., prints) only the desired output from a specific function --- in this case, just the correlation and p-value from the =Hmisc= package's =rcorr()= function. <highlight> library(Hmisc) myrho <- function (x, y) { rhosumm <- rcorr(x, y) rho <- round(rhosumm$r[1,2], 3) pval <- round(rhosumm$P[1,2], 4) c(Rho = rho, p.value = pval) } # Example y <- c(4, 1, 0, 1, 4) z <- c(1, 2, 3, 4, NA) myrho(y, z) </highlight> This user-defined function could easily extended to return the desired output from several different functions.
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r2
<
r1
|
B
acklinks
|
V
iew topic
|
Edit
w
iki text
|
M
ore topic actions
Topic revision: r2 - 10 Nov 2006,
TheresaScott
Main
Department Home Page
Biostatistics Graduate Program
Vanderbilt University Medical Center
Main Web
Main Web Home
Search
Recent Changes
Changes
Topic list
Biostatistics Webs
Archive
Main
Sandbox
System
Register
|
Log In
Copyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki?
Send feedback