You are here:
Vanderbilt Biostatistics Wiki
>
Main Web
>
Seminars
>
RClinic
>
WritingVectorList
(21 Nov 2006,
TheresaScott
)
(raw view)
E
dit
A
ttach
---+ Writing a list of vectors to a file Suppose you have a list whose components are vectors of different length, such as: <highlight> a <- list(comp1 = 1:2, comp2 = 3:6, comp3 = 7:9) </highlight> Here's how you can write the list to a file such that each component occupies a _row_ of the output file --- therefore, the output file has a different number of columns for each row. <highlight> cat(sapply(a, paste, collapse = "\t"), sep = "\n", file = "filename.txt") </highlight> In the previous code, we first collapse the elements of each vector to be tab delited (="\t"=), and then we write each vector to the file as separate rows (="\n"=).
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Edit
w
iki text
|
M
ore topic actions
Topic revision: r1 - 21 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