Skip to content
Back to formatted view

Raw Message

Message-ID: <004501cdb6bb$ed830a20$c8891e60$@tamu.edu>
Date: 2012-10-30T16:30:51Z
From: David L Carlson
Subject: newbie: embeding seq in a list
In-Reply-To: <CAELOVqBmnGAUQ7Wv1BtPqjLZCRgJ0RCyAHgeKZSq0r3gB5XKHg@mail.gmail.com>

Pass a vector to list() instead of individual values:

> env <- list(c(0.8,0.9,1.0,1.1,1.2))
> env
[[1]]
[1] 0.8 0.9 1.0 1.1 1.2

-------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Anser Chen
Sent: Tuesday, October 30, 2012 7:42 AM
To: r-help at r-project.org
Subject: [R] newbie: embeding seq in a list

Suppose I want to create a structure containing the following values:
0.8,0.9,1.0,1.1,1.2

If I use

env <- list(0.8,0.9,1.0,1.1,1.2)

then R returns

> env
[[1]]
[1] 0.8

[[2]]
[1] 0.9

[[3]]
[1] 1

[[4]]
[1] 1.1

[[5]]
[1] 1.2


But, if I try to 'save some key-strokes', and use


env <- list(seq(0.8,1.2,by=0.1))

then R returns

> env
[[1]]
[1] 0.8 0.9 1.0 1.1 1.2


I'd like the 'latter' to be equivalent to 'the former', but can't figure
out how to achieve said aim.

Thanks in advance...

	[[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.