[R] How do I generate a grid of data in [0,1]?
esh
esh at interchange.ubc.ca
Tue Aug 7 21:59:12 CEST 2007
Hello, my objective is to produce a data.frame that represents a grid of data points evenly spaced as closely together as possible on a graph with domain and range both being [0,1]. I tried to get a smaller example working first and I tried the following code:
> sink(file="Rsampledata")
> a<-0
> while(a<1) {data<-data.frame(a,seq(0,1,0.1)); print(data); a<-a+0.1}
My output was:
a seq.0..1..0.1.
1 0 0.0
2 0 0.1
3 0 0.2
4 0 0.3
5 0 0.4
6 0 0.5
7 0 0.6
8 0 0.7
9 0 0.8
10 0 0.9
11 0 1.0
a seq.0..1..0.1.
1 0.1 0.0
2 0.1 0.1
3 0.1 0.2
4 0.1 0.3
5 0.1 0.4
6 0.1 0.5
7 0.1 0.6
8 0.1 0.7
9 0.1 0.8
10 0.1 0.9
11 0.1 1.0
a seq.0..1..0.1.
1 0.2 0.0
2 0.2 0.1
3 0.2 0.2
4 0.2 0.3
5 0.2 0.4
6 0.2 0.5
7 0.2 0.6
8 0.2 0.7
9 0.2 0.8
10 0.2 0.9
11 0.2 1.0
a seq.0..1..0.1.
1 0.3 0.0
2 0.3 0.1
3 0.3 0.2
4 0.3 0.3
5 0.3 0.4
6 0.3 0.5
7 0.3 0.6
8 0.3 0.7
9 0.3 0.8
10 0.3 0.9
11 0.3 1.0
a seq.0..1..0.1.
1 0.4 0.0
2 0.4 0.1
3 0.4 0.2
4 0.4 0.3
5 0.4 0.4
6 0.4 0.5
7 0.4 0.6
8 0.4 0.7
9 0.4 0.8
10 0.4 0.9
11 0.4 1.0
a seq.0..1..0.1.
1 0.5 0.0
2 0.5 0.1
3 0.5 0.2
4 0.5 0.3
5 0.5 0.4
6 0.5 0.5
7 0.5 0.6
8 0.5 0.7
9 0.5 0.8
10 0.5 0.9
11 0.5 1.0
a seq.0..1..0.1.
1 0.6 0.0
2 0.6 0.1
3 0.6 0.2
4 0.6 0.3
5 0.6 0.4
6 0.6 0.5
7 0.6 0.6
8 0.6 0.7
9 0.6 0.8
10 0.6 0.9
11 0.6 1.0
a seq.0..1..0.1.
1 0.7 0.0
2 0.7 0.1
3 0.7 0.2
4 0.7 0.3
5 0.7 0.4
6 0.7 0.5
7 0.7 0.6
8 0.7 0.7
9 0.7 0.8
10 0.7 0.9
11 0.7 1.0
a seq.0..1..0.1.
1 0.8 0.0
2 0.8 0.1
3 0.8 0.2
4 0.8 0.3
5 0.8 0.4
6 0.8 0.5
7 0.8 0.6
8 0.8 0.7
9 0.8 0.8
10 0.8 0.9
11 0.8 1.0
a seq.0..1..0.1.
1 0.9 0.0
2 0.9 0.1
3 0.9 0.2
4 0.9 0.3
5 0.9 0.4
6 0.9 0.5
7 0.9 0.6
8 0.9 0.7
9 0.9 0.8
10 0.9 0.9
11 0.9 1.0
a seq.0..1..0.1.
1 1 0.0
2 1 0.1
3 1 0.2
4 1 0.3
5 1 0.4
6 1 0.5
7 1 0.6
8 1 0.7
9 1 0.8
10 1 0.9
11 1 1.0
This does produce the kind of data points that I will need, however I need all these data points in one single data.frame instead of 11 because of further formatting I must do with the data. Any suggestions?
Thank you,
Elysia
More information about the R-help
mailing list