Re: [R] how to create data.frame with dynamic count of values

2006-12-10 Thread Don MacQueen
Perhaps you didn't want a dataframe with columns N1 to N15 in it.

Perhaps the assign() function is what you are looking for. Something 
similar to:

nams - paste('N',1:15,sep='')
for (nm in nams) assign(nm,rep(0,VarSize))

-Don

At 10:14 PM +0100 12/8/06, Knut Krueger wrote:
Hello R-Group

I found how to fill the data.frame -
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70843.html

N1 - rnorm(4)
N2 - rnorm(4)
N3 - rnorm(4)
N4 - rnorm(4)
X1 - LETTERS[1:4]
###
nams - c(paste(N, 1:4, sep = ), X1)
dat - data.frame(lapply(nams, get))
names(dat) - nams
dat


But I need also to create a dynamic count of numeric vectors
items = 15
VarSize -10

N1 - rep(0,VarSize)
N2 - rep(0,VarSize)
N3 - rep(0,VarSize)
N4 - rep(0,VarSize)
N5 - rep(0,VarSize)
...
N15- rep(0,VarSize)  # 15 items


Thank you in advance
Knut

__
R-help@stat.math.ethz.ch 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.


-- 
-
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA

__
R-help@stat.math.ethz.ch 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.


Re: [R] how to create data.frame with dynamic count of values

2006-12-08 Thread Don MacQueen
I don't understand what you're asking for.

But if your goal is to create N1 through N15 in order to use them to 
fill a data frame, then it can be much simpler:

items - 15
VarSize - 10

tmp - matrix(0,nrow=VarSize,ncol=items)
tmp - data.frame(tmp)
names(tmp) - paste('N',seq(items),sep='')

## of course, this next only works if VarSize = length(letters)
tmp$X1 - letters[1:VarSize]

You could instead start with

tmp - matrix( rnorm(VarSize*items) , nrow=VarSize , ncol=items)

-Don

At 5:17 PM +0100 12/8/06, Knut Krueger wrote:
Hello R-Group

I found how to fill the data.frame -
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70843.html

N1 - rnorm(4)
N2 - rnorm(4)
N3 - rnorm(4)
N4 - rnorm(4)
X1 - LETTERS[1:4]
###
nams - c(paste(N, 1:4, sep = ), X1)
dat - data.frame(lapply(nams, get))
names(dat) - nams
dat


But I need also to create a dynamic count of numeric vectors
items = 15
VarSize -10

N1 - rep(0,VarSize)
N2 - rep(0,VarSize)
N3 - rep(0,VarSize)
N4 - rep(0,VarSize)
N5 - rep(0,VarSize)
...
N15- rep(0,VarSize)  # 15 items


Thank you in advance
Knut

__
R-help@stat.math.ethz.ch 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.


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

__
R-help@stat.math.ethz.ch 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.


Re: [R] how to create data.frame with dynamic count of values

2006-12-08 Thread jim holtman
Consider using a list:


 N - list()
 for (i in 1:15) N[[paste(N, i, sep='')]] - numeric(10)
 N
$N1
 [1] 0 0 0 0 0 0 0 0 0 0

$N2
 [1] 0 0 0 0 0 0 0 0 0 0

$N3
 [1] 0 0 0 0 0 0 0 0 0 0

$N4
 [1] 0 0 0 0 0 0 0 0 0 0

$N5
 [1] 0 0 0 0 0 0 0 0 0 0

$N6
 [1] 0 0 0 0 0 0 0 0 0 0

$N7
 [1] 0 0 0 0 0 0 0 0 0 0

$N8
 [1] 0 0 0 0 0 0 0 0 0 0

$N9
 [1] 0 0 0 0 0 0 0 0 0 0

$N10
 [1] 0 0 0 0 0 0 0 0 0 0

$N11
 [1] 0 0 0 0 0 0 0 0 0 0

$N12
 [1] 0 0 0 0 0 0 0 0 0 0

$N13
 [1] 0 0 0 0 0 0 0 0 0 0

$N14
 [1] 0 0 0 0 0 0 0 0 0 0

$N15
 [1] 0 0 0 0 0 0 0 0 0 0

 # access a specific element of the list
 N$N10
 [1] 0 0 0 0 0 0 0 0 0 0




On 12/8/06, Knut Krueger [EMAIL PROTECTED] wrote:

 Hello R-Group

 I found how to fill the data.frame -
 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70843.html

 N1 - rnorm(4)
 N2 - rnorm(4)
 N3 - rnorm(4)
 N4 - rnorm(4)
 X1 - LETTERS[1:4]
 ###
 nams - c(paste(N, 1:4, sep = ), X1)
 dat - data.frame(lapply(nams, get))
 names(dat) - nams
 dat


 But I need also to create a dynamic count of numeric vectors
 items = 15
 VarSize -10

 N1 - rep(0,VarSize)
 N2 - rep(0,VarSize)
 N3 - rep(0,VarSize)
 N4 - rep(0,VarSize)
 N5 - rep(0,VarSize)
 ...
 N15- rep(0,VarSize)  # 15 items


 Thank you in advance
 Knut

 __
 R-help@stat.math.ethz.ch 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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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.