[R] approximating matrix columns

2012-06-05 Thread eliza botto



Dear Gunter Berton and all,
As
you can see, my data has three lists each containing 366 entries. I converted
them into the matrix. I now want to approx./interpolate 366 entries over 365
intervals, Which means I want to have a matrix with 365 entries. 

I
used 

 

approx(matrix, method=”linear”,
n=365)

 

but
it only converted the first column of my data, and left the rest untouched.

 

 

list(c(0.86, 0.86, 0.86, 0.86, 0.86,
1.08, 1.08, 1.08, 1.08,

 1.08, 1.08, 1.4, 1.4, 23, 11.18, 38.83, 23,
3.45, 3.45, 3.45,

 3.45, 3.45, 3.45, 3.45, 3.45, 3.02, 2.58,
2.58, 2.15, 2.15, 2.15,

 2.15, 2.15, 2.15, 2.15, 2.15, 3.02, 1.72,
1.72, 1.72, 1.72, 1.72,

 1.72, 1.72, 1.72, 1.6, 1.6, 1.6, 1.6, 1.6,
1.6, 1.6, 1.6, 1.6,

 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6,
1.6, 1.6, 1.6, 1.6,

 1.6, 1.6, 1.6, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4,
2.4, 2.8, 2.8, 2.8,

 4.1, 4.1, 13.55, 9.34, 8.32, 7.31, 4.5, 4.1,
14.63, 24.88, 39.99,

 23.69, 14.63, 7.31, 4.5, 7.31, 16.82, 21.35,
24.88, 20.2, 24.88,

 26.07, 30.98, 49.58, 51.01, 26.07, 24.88,
30.98, 34.77, 58.26,

 30.98, 23.69, 26.07, 19.06, 16.82, 20.2,
16.82, 23.69, 14.63,

 16.82, 11.42, 11.42, 11.42, 11.42, 10.38,
10.38, 8.32, 7.31,

 6.31, 16.82, 6.31, 6.31, 6.31, 4.9, 4.9, 4.5,
4.5, 4.5, 4.5,

 4.5, 4.1, 4.1, 2.8, 2.4, 2.4, 26.07, 45.4,
16.82, 7.31, 4.5,

 3.2, 3.2, 2.8, 2.8, 2.4, 2.4, 2.8, 3.2, 3.2,
4.9, 4.9, 36.05,

 65.8, 76.86, 53.87, 26.07, 20.2, 21.36, 14.63,
10.38, 10.38,

 7.31, 7.31, 51.01, 16.82, 14.63, 12.48, 14.63,
10.38, 11.42,

 52.44, 64.27, 36.05, 26.07, 21.36, 21.36,
23.69, 47.79, 52.44,

 167.9, 97.12, 76.86, 144.71, 90.18, 34.77,
30.98, 28.5, 26.07,

 26.07, 14.63, 14.63, 6.31, 6.31, 6.31, 4.5,
4.1, 3.2, 6.31, 6.31,

 16.82, 4.5, 3.2, 3.2, 3.2, 3.2, 4.5, 8.32,
10.38, 10.38, 8.32,

 11.42, 10.38, 7.31, 6.31, 6.31, 6.31, 6.31,
6.31, 6.31, 6.31,

 8.32, 6.31, 6.31, 20.2, 14.63, 7.31, 4.9,
34.77, 26.07, 14.63,

 10.38, 6.31, 4.9, 7.31, 4.9, 4.5, 4.5, 4.5,
21.36, 12.48, 7.31,

 4.5, 4.5, 6.31, 4.9, 4.9, 6.31, 8.32, 7.31,
6.31, 6.31, 14.63,

 11.42, 6.31, 6.31, 4.9, 6.31, 14.63, 7.31,
12.48, 6.31, 6.31,

 24.88, 15.72, 33.49, 111.57, 44.03, 39.99,
44.03, 24.88, 12.48,

 39.99, 11.42, 7.31, 4.9, 4.5, 4.1, 4.5, 4.1,
4.1, 3.2, 3.2, 3.2,

 3.2, 3.2, 2.8, 2.8, 3.2, 3.2, 3.2, 3.2, 3.2,
3.2, 3.2, 2.8, 2.8,

 3.2, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8,
2.8, 2.8, 2.8, 2.8,

 4.1, 4.1, 2.4, 3.2, 10.38, 8.32, 4.5, 3.2,
3.2, 2.8, 3.2, 3.2,

 3.2, 2.4, 2.4, 2.4, 15.72, 23.69, 12.48,
14.63, 4.5, 4.1, 4.5,

 4.1, 4.1, 4.1, 3.2, 2.8, 2.8, 3.2, 2.8, 2.4,
4.5, 4.5, 12.48,

 68.9, 30.98, 39.99, 29.73, 95.37, 44.03,
26.07, 41.33, 49.58,

 23.69, 28.5), c(16.82, 14.63, 6.31, 6.31, 4.5, 4.5, 4.1, 4.1,

 4.1, 3.2, 3.2, 4.1, 3.2, 3.2, 4.1, 4.5, 4.1,
4.1, 167.9, 75.24,

 44.03, 23.69, 19.06, 15.72, 11.42, 8.32, 6.31,
4.9, 6.31, 4.9,

 4.9, 4.1, 4.1, 3.2, 4.1, 4.1, 4.1, 90.18,
102.45, 39.99, 29.73,

 8.32, 21.36, 21.36, 21.36, 12.48, 11.42,
12.48, 11.42, 12.48,

 14.63, 14.63, 15.72, 23.69, 28.5, 29.73,
33.49, 29.73, 23.69,

 21.36, 6.31, 16.82, 15.72, 15.72, 15.72,
15.72, 16.82, 20.2,

 20.2, 21.36, 21.36, 26.07, 28.5, 29.73, 33.49,
29.73, 33.49,

 34.77, 26.07, 26.07, 23.69, 23.69, 26.07,
21.36, 23.69, 23.69,

 23.69, 24.88, 21.36, 20.2, 16.82, 19.06, 20.2,
21.36, 20.2, 20.2,

 24.88, 23.69, 26.07, 29.73, 23.69, 24.88,
29.73, 36.05, 33.49,

 34.77, 28.5, 28.5, 26.07, 153, 70.47, 58.26,
81.77, 36.05, 39.99,

 30.98, 33.49, 28.5, 28.5, 33.49, 29.73, 28.5,
24.88, 30.98, 38.67,

 30.98, 50.01, 65.8, 51.01, 38.67, 34.77,
29.73, 29.73, 33.49,

 30.98, 30.98, 30.98, 33.49, 34.77, 33.49,
30.98, 88.48, 14.63,

 8.32, 19.06, 14.63, 104.25, 44.03, 33.49,
21.36, 20.2, 15.72,

 15.72, 11.42, 7.31, 6.31, 4.9, 4.5, 4.5, 4.5,
3.2, 8.32, 8.32,

 14.63, 97.12, 310.8, 88.48, 36.05, 24.88,
19.06, 14.63, 12.48,

 8.32, 23.69, 11.42, 19.06, 90.18, 90.18,
33.49, 16.82, 70.47,

 38.67, 29.73, 34.77, 33.49, 68.9, 102.45,
176.7, 78.48, 45.4,

 106.06, 83.43, 45.4, 68.9, 39.99, 28.5, 23.69,
20.2, 36.05, 38.67,

 30.98, 26.07, 20.2, 47.79, 52.44, 28.5, 23.69,
20.2, 14.63, 14.63,

 14.63, 12.48, 21.36, 24.88, 47.79, 38.67,
34.77, 21.36, 16.82,

 8.32, 153, 47.79, 53.87, 29.73, 23.69, 15.72,
19.06, 97.12, 33.49,

 15.72, 10.38, 6.31, 4.5, 11.42, 6.31, 6.31,
6.31, 4.5, 19.06,

 14.63, 4.9, 4.9, 28.5, 70.47, 15.72, 4.9, 4.1,
41.33, 241, 85.1,

 38.67, 28.5, 20.2, 15.72, 12.48, 12.48, 20.2,
14.63, 12.48, 10.38,

 7.31, 7.31, 15.72, 33.49, 20.2, 15.72, 12.48,
8.32, 7.31, 6.31,

 4.9, 4.5, 4.1, 4.9, 4.5, 4.9, 20.2, 11.42,
6.31, 4.9, 4.9, 4.9,

 4.5, 4.5, 4.5, 4.1, 4.1, 4.1, 4.1, 4.1, 4.1,
4.1, 4.1, 4.1, 6.31,

 6.31, 4.5, 4.9, 4.9, 4.5, 4.5, 4.5, 4.9, 4.5,
15.72, 24.88, 4.1,

 58.26, 23.69, 26.07, 28.5, 174.5, 58.26,
49.58, 23.69, 23.69,

 23.69, 28.5, 

Re: [R] approximating matrix columns

2012-06-05 Thread Rui Barradas

Hello,

Try

apply(mat, 2, approx, method=”linear”, n=365)

This reads apply to each column (dimension = 2) of mat the function 
approx with extra args method and n.


Three notes.
1. Your data does NOT have three list, it IS one list with three vectors.
2. 'matrix' is a function so choose something else as a name. Above I've 
chosen 'mat'.
3. Bert is obviously right. You are wrong in not following simple 
posting instructions. And in not even bothering to quote his post.


Rui Barradas

Em 05-06-2012 09:27, eliza botto escreveu:



Dear Gunter Berton and all,
As
you can see, my data has three lists each containing 366 entries. I converted
them into the matrix. I now want to approx./interpolate 366 entries over 365
intervals, Which means I want to have a matrix with 365 entries.

I
used



approx(matrix, method=”linear”,
n=365)



but
it only converted the first column of my data, and left the rest untouched.





list(c(0.86, 0.86, 0.86, 0.86, 0.86,
1.08, 1.08, 1.08, 1.08,

  1.08, 1.08, 1.4, 1.4, 23, 11.18, 38.83, 23,
3.45, 3.45, 3.45,

  3.45, 3.45, 3.45, 3.45, 3.45, 3.02, 2.58,
2.58, 2.15, 2.15, 2.15,

  2.15, 2.15, 2.15, 2.15, 2.15, 3.02, 1.72,
1.72, 1.72, 1.72, 1.72,

  1.72, 1.72, 1.72, 1.6, 1.6, 1.6, 1.6, 1.6,
1.6, 1.6, 1.6, 1.6,

  1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6,
1.6, 1.6, 1.6, 1.6,

  1.6, 1.6, 1.6, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4,
2.4, 2.8, 2.8, 2.8,

  4.1, 4.1, 13.55, 9.34, 8.32, 7.31, 4.5, 4.1,
14.63, 24.88, 39.99,

  23.69, 14.63, 7.31, 4.5, 7.31, 16.82, 21.35,
24.88, 20.2, 24.88,

  26.07, 30.98, 49.58, 51.01, 26.07, 24.88,
30.98, 34.77, 58.26,

  30.98, 23.69, 26.07, 19.06, 16.82, 20.2,
16.82, 23.69, 14.63,

  16.82, 11.42, 11.42, 11.42, 11.42, 10.38,
10.38, 8.32, 7.31,

  6.31, 16.82, 6.31, 6.31, 6.31, 4.9, 4.9, 4.5,
4.5, 4.5, 4.5,

  4.5, 4.1, 4.1, 2.8, 2.4, 2.4, 26.07, 45.4,
16.82, 7.31, 4.5,

  3.2, 3.2, 2.8, 2.8, 2.4, 2.4, 2.8, 3.2, 3.2,
4.9, 4.9, 36.05,

  65.8, 76.86, 53.87, 26.07, 20.2, 21.36, 14.63,
10.38, 10.38,

  7.31, 7.31, 51.01, 16.82, 14.63, 12.48, 14.63,
10.38, 11.42,

  52.44, 64.27, 36.05, 26.07, 21.36, 21.36,
23.69, 47.79, 52.44,

  167.9, 97.12, 76.86, 144.71, 90.18, 34.77,
30.98, 28.5, 26.07,

  26.07, 14.63, 14.63, 6.31, 6.31, 6.31, 4.5,
4.1, 3.2, 6.31, 6.31,

  16.82, 4.5, 3.2, 3.2, 3.2, 3.2, 4.5, 8.32,
10.38, 10.38, 8.32,

  11.42, 10.38, 7.31, 6.31, 6.31, 6.31, 6.31,
6.31, 6.31, 6.31,

  8.32, 6.31, 6.31, 20.2, 14.63, 7.31, 4.9,
34.77, 26.07, 14.63,

  10.38, 6.31, 4.9, 7.31, 4.9, 4.5, 4.5, 4.5,
21.36, 12.48, 7.31,

  4.5, 4.5, 6.31, 4.9, 4.9, 6.31, 8.32, 7.31,
6.31, 6.31, 14.63,

  11.42, 6.31, 6.31, 4.9, 6.31, 14.63, 7.31,
12.48, 6.31, 6.31,

  24.88, 15.72, 33.49, 111.57, 44.03, 39.99,
44.03, 24.88, 12.48,

  39.99, 11.42, 7.31, 4.9, 4.5, 4.1, 4.5, 4.1,
4.1, 3.2, 3.2, 3.2,

  3.2, 3.2, 2.8, 2.8, 3.2, 3.2, 3.2, 3.2, 3.2,
3.2, 3.2, 2.8, 2.8,

  3.2, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8,
2.8, 2.8, 2.8, 2.8,

  4.1, 4.1, 2.4, 3.2, 10.38, 8.32, 4.5, 3.2,
3.2, 2.8, 3.2, 3.2,

  3.2, 2.4, 2.4, 2.4, 15.72, 23.69, 12.48,
14.63, 4.5, 4.1, 4.5,

  4.1, 4.1, 4.1, 3.2, 2.8, 2.8, 3.2, 2.8, 2.4,
4.5, 4.5, 12.48,

  68.9, 30.98, 39.99, 29.73, 95.37, 44.03,
26.07, 41.33, 49.58,

  23.69, 28.5), c(16.82, 14.63, 6.31, 6.31, 4.5, 4.5, 4.1, 4.1,

  4.1, 3.2, 3.2, 4.1, 3.2, 3.2, 4.1, 4.5, 4.1,
4.1, 167.9, 75.24,

  44.03, 23.69, 19.06, 15.72, 11.42, 8.32, 6.31,
4.9, 6.31, 4.9,

  4.9, 4.1, 4.1, 3.2, 4.1, 4.1, 4.1, 90.18,
102.45, 39.99, 29.73,

  8.32, 21.36, 21.36, 21.36, 12.48, 11.42,
12.48, 11.42, 12.48,

  14.63, 14.63, 15.72, 23.69, 28.5, 29.73,
33.49, 29.73, 23.69,

  21.36, 6.31, 16.82, 15.72, 15.72, 15.72,
15.72, 16.82, 20.2,

  20.2, 21.36, 21.36, 26.07, 28.5, 29.73, 33.49,
29.73, 33.49,

  34.77, 26.07, 26.07, 23.69, 23.69, 26.07,
21.36, 23.69, 23.69,

  23.69, 24.88, 21.36, 20.2, 16.82, 19.06, 20.2,
21.36, 20.2, 20.2,

  24.88, 23.69, 26.07, 29.73, 23.69, 24.88,
29.73, 36.05, 33.49,

  34.77, 28.5, 28.5, 26.07, 153, 70.47, 58.26,
81.77, 36.05, 39.99,

  30.98, 33.49, 28.5, 28.5, 33.49, 29.73, 28.5,
24.88, 30.98, 38.67,

  30.98, 50.01, 65.8, 51.01, 38.67, 34.77,
29.73, 29.73, 33.49,

  30.98, 30.98, 30.98, 33.49, 34.77, 33.49,
30.98, 88.48, 14.63,

  8.32, 19.06, 14.63, 104.25, 44.03, 33.49,
21.36, 20.2, 15.72,

  15.72, 11.42, 7.31, 6.31, 4.9, 4.5, 4.5, 4.5,
3.2, 8.32, 8.32,

  14.63, 97.12, 310.8, 88.48, 36.05, 24.88,
19.06, 14.63, 12.48,

  8.32, 23.69, 11.42, 19.06, 90.18, 90.18,
33.49, 16.82, 70.47,

  38.67, 29.73, 34.77, 33.49, 68.9, 102.45,
176.7, 78.48, 45.4,

  106.06, 83.43, 45.4, 68.9, 39.99, 28.5, 23.69,
20.2, 36.05, 38.67,

  30.98, 26.07, 20.2, 47.79, 52.44, 28.5, 23.69,
20.2, 14.63, 14.63,

  14.63, 12.48, 21.36, 24.88, 47.79, 38.67,
34.77, 21.36, 16.82,

  8.32, 153, 47.79, 53.87, 29.73, 23.69, 15.72,
19.06, 97.12, 

Re: [R] approximating matrix columns

2012-06-05 Thread eliza botto

Dear Rui,
i am greatful for everything you did. bret advised me to use dput(), which i 
did. yes! i forgot to complement him. i literally feel sorry for that. i hope 
you wont mind and continue extending your help.
regards and love for every one
eliza botto
waters inn

 Date: Tue, 5 Jun 2012 12:46:25 +0100
 From: ruipbarra...@sapo.pt
 To: eliza_bo...@hotmail.com
 CC: r-help@r-project.org
 Subject: Re: approximating matrix columns
 
 Hello,
 
 Try
 
 apply(mat, 2, approx, method=”linear”, n=365)
 
 This reads apply to each column (dimension = 2) of mat the function 
 approx with extra args method and n.
 
 Three notes.
 1. Your data does NOT have three list, it IS one list with three vectors.
 2. 'matrix' is a function so choose something else as a name. Above I've 
 chosen 'mat'.
 3. Bert is obviously right. You are wrong in not following simple 
 posting instructions. And in not even bothering to quote his post.
 
 Rui Barradas
 
 Em 05-06-2012 09:27, eliza botto escreveu:
 
 
  Dear Gunter Berton and all,
  As
  you can see, my data has three lists each containing 366 entries. I 
  converted
  them into the matrix. I now want to approx./interpolate 366 entries over 365
  intervals, Which means I want to have a matrix with 365 entries.
 
  I
  used
 
 
 
  approx(matrix, method=”linear”,
  n=365)
 
 
 
  but
  it only converted the first column of my data, and left the rest untouched.
 
 
 
 
 
  list(c(0.86, 0.86, 0.86, 0.86, 0.86,
  1.08, 1.08, 1.08, 1.08,
 
1.08, 1.08, 1.4, 1.4, 23, 11.18, 38.83, 23,
  3.45, 3.45, 3.45,
 
3.45, 3.45, 3.45, 3.45, 3.45, 3.02, 2.58,
  2.58, 2.15, 2.15, 2.15,
 
2.15, 2.15, 2.15, 2.15, 2.15, 3.02, 1.72,
  1.72, 1.72, 1.72, 1.72,
 
1.72, 1.72, 1.72, 1.6, 1.6, 1.6, 1.6, 1.6,
  1.6, 1.6, 1.6, 1.6,
 
1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6,
  1.6, 1.6, 1.6, 1.6,
 
1.6, 1.6, 1.6, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4,
  2.4, 2.8, 2.8, 2.8,
 
4.1, 4.1, 13.55, 9.34, 8.32, 7.31, 4.5, 4.1,
  14.63, 24.88, 39.99,
 
23.69, 14.63, 7.31, 4.5, 7.31, 16.82, 21.35,
  24.88, 20.2, 24.88,
 
26.07, 30.98, 49.58, 51.01, 26.07, 24.88,
  30.98, 34.77, 58.26,
 
30.98, 23.69, 26.07, 19.06, 16.82, 20.2,
  16.82, 23.69, 14.63,
 
16.82, 11.42, 11.42, 11.42, 11.42, 10.38,
  10.38, 8.32, 7.31,
 
6.31, 16.82, 6.31, 6.31, 6.31, 4.9, 4.9, 4.5,
  4.5, 4.5, 4.5,
 
4.5, 4.1, 4.1, 2.8, 2.4, 2.4, 26.07, 45.4,
  16.82, 7.31, 4.5,
 
3.2, 3.2, 2.8, 2.8, 2.4, 2.4, 2.8, 3.2, 3.2,
  4.9, 4.9, 36.05,
 
65.8, 76.86, 53.87, 26.07, 20.2, 21.36, 14.63,
  10.38, 10.38,
 
7.31, 7.31, 51.01, 16.82, 14.63, 12.48, 14.63,
  10.38, 11.42,
 
52.44, 64.27, 36.05, 26.07, 21.36, 21.36,
  23.69, 47.79, 52.44,
 
167.9, 97.12, 76.86, 144.71, 90.18, 34.77,
  30.98, 28.5, 26.07,
 
26.07, 14.63, 14.63, 6.31, 6.31, 6.31, 4.5,
  4.1, 3.2, 6.31, 6.31,
 
16.82, 4.5, 3.2, 3.2, 3.2, 3.2, 4.5, 8.32,
  10.38, 10.38, 8.32,
 
11.42, 10.38, 7.31, 6.31, 6.31, 6.31, 6.31,
  6.31, 6.31, 6.31,
 
8.32, 6.31, 6.31, 20.2, 14.63, 7.31, 4.9,
  34.77, 26.07, 14.63,
 
10.38, 6.31, 4.9, 7.31, 4.9, 4.5, 4.5, 4.5,
  21.36, 12.48, 7.31,
 
4.5, 4.5, 6.31, 4.9, 4.9, 6.31, 8.32, 7.31,
  6.31, 6.31, 14.63,
 
11.42, 6.31, 6.31, 4.9, 6.31, 14.63, 7.31,
  12.48, 6.31, 6.31,
 
24.88, 15.72, 33.49, 111.57, 44.03, 39.99,
  44.03, 24.88, 12.48,
 
39.99, 11.42, 7.31, 4.9, 4.5, 4.1, 4.5, 4.1,
  4.1, 3.2, 3.2, 3.2,
 
3.2, 3.2, 2.8, 2.8, 3.2, 3.2, 3.2, 3.2, 3.2,
  3.2, 3.2, 2.8, 2.8,
 
3.2, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8,
  2.8, 2.8, 2.8, 2.8,
 
4.1, 4.1, 2.4, 3.2, 10.38, 8.32, 4.5, 3.2,
  3.2, 2.8, 3.2, 3.2,
 
3.2, 2.4, 2.4, 2.4, 15.72, 23.69, 12.48,
  14.63, 4.5, 4.1, 4.5,
 
4.1, 4.1, 4.1, 3.2, 2.8, 2.8, 3.2, 2.8, 2.4,
  4.5, 4.5, 12.48,
 
68.9, 30.98, 39.99, 29.73, 95.37, 44.03,
  26.07, 41.33, 49.58,
 
23.69, 28.5), c(16.82, 14.63, 6.31, 6.31, 4.5, 4.5, 4.1, 4.1,
 
4.1, 3.2, 3.2, 4.1, 3.2, 3.2, 4.1, 4.5, 4.1,
  4.1, 167.9, 75.24,
 
44.03, 23.69, 19.06, 15.72, 11.42, 8.32, 6.31,
  4.9, 6.31, 4.9,
 
4.9, 4.1, 4.1, 3.2, 4.1, 4.1, 4.1, 90.18,
  102.45, 39.99, 29.73,
 
8.32, 21.36, 21.36, 21.36, 12.48, 11.42,
  12.48, 11.42, 12.48,
 
14.63, 14.63, 15.72, 23.69, 28.5, 29.73,
  33.49, 29.73, 23.69,
 
21.36, 6.31, 16.82, 15.72, 15.72, 15.72,
  15.72, 16.82, 20.2,
 
20.2, 21.36, 21.36, 26.07, 28.5, 29.73, 33.49,
  29.73, 33.49,
 
34.77, 26.07, 26.07, 23.69, 23.69, 26.07,
  21.36, 23.69, 23.69,
 
23.69, 24.88, 21.36, 20.2, 16.82, 19.06, 20.2,
  21.36, 20.2, 20.2,
 
24.88, 23.69, 26.07, 29.73, 23.69, 24.88,
  29.73, 36.05, 33.49,
 
34.77, 28.5, 28.5, 26.07, 153, 70.47, 58.26,
  81.77, 36.05, 39.99,
 
30.98, 33.49, 28.5, 28.5, 33.49, 29.73, 28.5,
  24.88, 30.98, 38.67,
 
30.98, 50.01, 65.8, 51.01, 38.67, 34.77,
 

[R] approximating matrix columns

2012-06-04 Thread eliza botto

 Dear R users,
 we generally apply approx() command to a list data. how can we apply this 
command to a matrix, so that we can approximate 366 readings from certain 
number of each column over 365 intervals?? more precisely, i want to 
interpolate 366 discharge readings, in each 8 columns of a matrix, over 365 
days.
 hope i am clear in my statement.
eliza botto
  
  
   From: eliza_bo...@hotmail.com
   To: ruipbarra...@sapo.pt
   Date: Mon, 4 Jun 2012 22:13:10 +
   CC: r-help@r-project.org
   Subject: Re: [R] Spliting Lists into matrices
   
   
   
   
   
   
   dear rui,
   lots of hugs for you.
   thnkyou very much 4 your support.
   eliza
   
Date: Mon, 4 Jun 2012 22:58:12 +0100
From: ruipbarra...@sapo.pt
To: eliza_bo...@hotmail.com
CC: r-help@r-project.org
Subject: Re: Spliting Lists into matrices

Hello,

Try

# 'x' is your list
xlen - sapply(x, length)
i1 - which(xlen == 365)
i2 - which(xlen == 366)

mat365 - matrix(unlist(x[i1]), nrow=365)
mat366 - matrix(unlist(x[i2]), nrow=366)


Hope this helps,

Rui Barradas

Em 04-06-2012 22:46, eliza botto escreveu:
 i realy appreciate your concern..
 here is a small piece of my data. if you see the first and last part 
 data, they contain 366 entries but the middle one has 365 entries. i 
 want to put first and last entries is one matrix.

 list(c(0.86, 0.86, 0.86, 0.86, 0.86, 1.08, 1.08, 1.08, 1.08,
 1.08, 1.08, 1.4, 1.4, 23, 11.18, 38.83, 23, 3.45, 3.45, 3.45,
 3.45, 3.45, 3.45, 3.45, 3.45, 3.02, 2.58, 2.58, 2.15, 2.15, 2.15,
 2.15, 2.15, 2.15, 2.15, 2.15, 3.02, 1.72, 1.72, 1.72, 1.72, 1.72,
 1.72, 1.72, 1.72, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6,
 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6,
 1.6, 1.6, 1.6, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.8, 2.8, 2.8,
 4.1, 4.1, 13.55, 9.34, 8.32, 7.31, 4.5, 4.1, 14.63, 24.88, 39.99,
 23.69, 14.63, 7.31, 4.5, 7.31, 16.82, 21.35, 24.88, 20.2, 24.88,
 26.07, 30.98, 49.58, 51.01, 26.07, 24.88, 30.98, 34.77, 58.26,
 30.98, 23.69, 26.07, 19.06, 16.82, 20.2, 16.82, 23.69, 14.63,
 16.82, 11.42, 11.42, 11.42, 11.42, 10.38, 10.38, 8.32, 7.31,
 6.31, 16.82, 6.31, 6.31, 6.31, 4.9, 4.9, 4.5, 4.5, 4.5, 4.5,
 4.5, 4.1, 4.1, 2.8, 2.4, 2.4, 26.07, 45.4, 16.82, 7.31, 4.5,
 3.2, 3.2, 2.8, 2.8, 2.4, 2.4, 2.8, 3.2, 3.2, 4.9, 4.9, 36.05,
 65.8, 76.86, 53.87, 26.07, 20.2, 21.36, 14.63, 10.38, 10.38,
 7.31, 7.31, 51.01, 16.82, 14.63, 12.48, 14.63, 10.38, 11.42,
 52.44, 64.27, 36.05, 26.07, 21.36, 21.36, 23.69, 47.79, 52.44,
 167.9, 97.12, 76.86, 144.71, 90.18, 34.77, 30.98, 28.5, 26.07,
 26.07, 14.63, 14.63, 6.31, 6.31, 6.31, 4.5, 4.1, 3.2, 6.31, 6.31,
 16.82, 4.5, 3.2, 3.2, 3.2, 3.2, 4.5, 8.32, 10.38, 10.38, 8.32,
 11.42, 10.38, 7.31, 6.31, 6.31, 6.31, 6.31, 6.31, 6.31, 6.31,
 8.32, 6.31, 6.31, 20.2, 14.63, 7.31, 4.9, 34.77, 26.07, 14.63,
 10.38, 6.31, 4.9, 7.31, 4.9, 4.5, 4.5, 4.5, 21.36, 12.48, 7.31,
 4.5, 4.5, 6.31, 4.9, 4.9, 6.31, 8.32, 7.31, 6.31, 6.31, 14.63,
 11.42, 6.31, 6.31, 4.9, 6.31, 14.63, 7.31, 12.48, 6.31, 6.31,
 24.88, 15.72, 33.49, 111.57, 44.03, 39.99, 44.03, 24.88, 12.48,
 39.99, 11.42, 7.31, 4.9, 4.5, 4.1, 4.5, 4.1, 4.1, 3.2, 3.2, 3.2,
 3.2, 3.2, 2.8, 2.8, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 2.8, 2.8,
 3.2, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8,
 4.1, 4.1, 2.4, 3.2, 10.38, 8.32, 4.5, 3.2, 3.2, 2.8, 3.2, 3.2,
 3.2, 2.4, 2.4, 2.4, 15.72, 23.69, 12.48, 14.63, 4.5, 4.1, 4.5,
 4.1, 4.1, 4.1, 3.2, 2.8, 2.8, 3.2, 2.8, 2.4, 4.5, 4.5, 12.48,
 68.9, 30.98, 39.99, 29.73, 95.37, 44.03, 26.07, 41.33, 49.58,
 23.69, 28.5), c(16.82, 14.63, 6.31, 6.31, 4.5, 4.5, 4.1, 4.1,
 4.1, 3.2, 3.2, 4.1, 3.2, 3.2, 4.1, 4.5, 4.1, 4.1, 167.9, 75.24,
 44.03, 23.69, 19.06, 15.72, 11.42, 8.32, 6.31, 4.9, 6.31, 4.9,
 4.9, 4.1, 4.1, 3.2, 4.1, 4.1, 4.1, 90.18, 102.45, 39.99, 29.73,
 8.32, 21.36, 21.36, 21.36, 12.48, 11.42, 12.48, 11.42, 12.48,
 14.63, 14.63, 15.72, 23.69, 28.5, 29.73, 33.49, 29.73, 23.69,
 21.36, 6.31, 16.82, 15.72, 15.72, 15.72, 15.72, 16.82, 20.2,
 20.2, 21.36, 21.36, 26.07, 28.5, 29.73, 33.49, 29.73, 33.49,
 34.77, 26.07, 26.07, 23.69, 23.69, 26.07, 21.36, 23.69, 23.69,
 23.69, 24.88, 21.36, 20.2, 16.82, 19.06, 20.2, 21.36, 20.2, 20.2,
 24.88, 23.69, 26.07, 29.73, 23.69, 24.88, 29.73, 36.05, 33.49,
 34.77, 28.5, 28.5, 26.07, 153, 70.47, 58.26, 81.77, 36.05, 39.99,
 30.98, 33.49, 28.5, 28.5, 33.49, 29.73, 28.5, 24.88, 30.98, 38.67,
 30.98, 50.01, 65.8, 51.01, 38.67, 34.77, 29.73, 29.73, 33.49,
 30.98, 30.98, 30.98, 33.49, 34.77, 33.49, 30.98, 88.48, 14.63,
 8.32, 19.06, 14.63, 104.25, 44.03, 33.49, 21.36, 20.2, 15.72,
 15.72, 11.42, 7.31, 6.31, 4.9, 4.5, 4.5, 4.5, 3.2, 8.32, 8.32,
 14.63, 97.12, 310.8, 88.48, 36.05, 24.88, 19.06, 14.63, 12.48,
 8.32, 23.69, 

Re: [R] approximating matrix columns

2012-06-04 Thread Bert Gunter
1. Please follow the posting guide and provide a small reproducible
example. See ?dput to provide data.

2. Please do not double post.

-- Bert

On Mon, Jun 4, 2012 at 4:47 PM, eliza botto eliza_bo...@hotmail.com wrote:

  Dear R users,
  we generally apply approx() command to a list data. how can we apply this 
 command to a matrix, so that we can approximate 366 readings from certain 
 number of each column over 365 intervals?? more precisely, i want to 
 interpolate 366 discharge readings, in each 8 columns of a matrix, over 365 
 days.
  hope i am clear in my statement.
 eliza botto
 
 
   From: eliza_bo...@hotmail.com
   To: ruipbarra...@sapo.pt
   Date: Mon, 4 Jun 2012 22:13:10 +
   CC: r-help@r-project.org
   Subject: Re: [R] Spliting Lists into matrices
  
  
  
  
  
  
   dear rui,
   lots of hugs for you.
   thnkyou very much 4 your support.
   eliza
  
Date: Mon, 4 Jun 2012 22:58:12 +0100
From: ruipbarra...@sapo.pt
To: eliza_bo...@hotmail.com
CC: r-help@r-project.org
Subject: Re: Spliting Lists into matrices
   
Hello,
   
Try
   
# 'x' is your list
xlen - sapply(x, length)
i1 - which(xlen == 365)
i2 - which(xlen == 366)
   
mat365 - matrix(unlist(x[i1]), nrow=365)
mat366 - matrix(unlist(x[i2]), nrow=366)
   
   
Hope this helps,
   
Rui Barradas
   
Em 04-06-2012 22:46, eliza botto escreveu:
 i realy appreciate your concern..
 here is a small piece of my data. if you see the first and last part 
 data, they contain 366 entries but the middle one has 365 entries. i 
 want to put first and last entries is one matrix.

 list(c(0.86, 0.86, 0.86, 0.86, 0.86, 1.08, 1.08, 1.08, 1.08,
 1.08, 1.08, 1.4, 1.4, 23, 11.18, 38.83, 23, 3.45, 3.45, 3.45,
 3.45, 3.45, 3.45, 3.45, 3.45, 3.02, 2.58, 2.58, 2.15, 2.15, 2.15,
 2.15, 2.15, 2.15, 2.15, 2.15, 3.02, 1.72, 1.72, 1.72, 1.72, 1.72,
 1.72, 1.72, 1.72, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6,
 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6,
 1.6, 1.6, 1.6, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.8, 2.8, 2.8,
 4.1, 4.1, 13.55, 9.34, 8.32, 7.31, 4.5, 4.1, 14.63, 24.88, 39.99,
 23.69, 14.63, 7.31, 4.5, 7.31, 16.82, 21.35, 24.88, 20.2, 24.88,
 26.07, 30.98, 49.58, 51.01, 26.07, 24.88, 30.98, 34.77, 58.26,
 30.98, 23.69, 26.07, 19.06, 16.82, 20.2, 16.82, 23.69, 14.63,
 16.82, 11.42, 11.42, 11.42, 11.42, 10.38, 10.38, 8.32, 7.31,
 6.31, 16.82, 6.31, 6.31, 6.31, 4.9, 4.9, 4.5, 4.5, 4.5, 4.5,
 4.5, 4.1, 4.1, 2.8, 2.4, 2.4, 26.07, 45.4, 16.82, 7.31, 4.5,
 3.2, 3.2, 2.8, 2.8, 2.4, 2.4, 2.8, 3.2, 3.2, 4.9, 4.9, 36.05,
 65.8, 76.86, 53.87, 26.07, 20.2, 21.36, 14.63, 10.38, 10.38,
 7.31, 7.31, 51.01, 16.82, 14.63, 12.48, 14.63, 10.38, 11.42,
 52.44, 64.27, 36.05, 26.07, 21.36, 21.36, 23.69, 47.79, 52.44,
 167.9, 97.12, 76.86, 144.71, 90.18, 34.77, 30.98, 28.5, 26.07,
 26.07, 14.63, 14.63, 6.31, 6.31, 6.31, 4.5, 4.1, 3.2, 6.31, 6.31,
 16.82, 4.5, 3.2, 3.2, 3.2, 3.2, 4.5, 8.32, 10.38, 10.38, 8.32,
 11.42, 10.38, 7.31, 6.31, 6.31, 6.31, 6.31, 6.31, 6.31, 6.31,
 8.32, 6.31, 6.31, 20.2, 14.63, 7.31, 4.9, 34.77, 26.07, 14.63,
 10.38, 6.31, 4.9, 7.31, 4.9, 4.5, 4.5, 4.5, 21.36, 12.48, 7.31,
 4.5, 4.5, 6.31, 4.9, 4.9, 6.31, 8.32, 7.31, 6.31, 6.31, 14.63,
 11.42, 6.31, 6.31, 4.9, 6.31, 14.63, 7.31, 12.48, 6.31, 6.31,
 24.88, 15.72, 33.49, 111.57, 44.03, 39.99, 44.03, 24.88, 12.48,
 39.99, 11.42, 7.31, 4.9, 4.5, 4.1, 4.5, 4.1, 4.1, 3.2, 3.2, 3.2,
 3.2, 3.2, 2.8, 2.8, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 2.8, 2.8,
 3.2, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8,
 4.1, 4.1, 2.4, 3.2, 10.38, 8.32, 4.5, 3.2, 3.2, 2.8, 3.2, 3.2,
 3.2, 2.4, 2.4, 2.4, 15.72, 23.69, 12.48, 14.63, 4.5, 4.1, 4.5,
 4.1, 4.1, 4.1, 3.2, 2.8, 2.8, 3.2, 2.8, 2.4, 4.5, 4.5, 12.48,
 68.9, 30.98, 39.99, 29.73, 95.37, 44.03, 26.07, 41.33, 49.58,
 23.69, 28.5), c(16.82, 14.63, 6.31, 6.31, 4.5, 4.5, 4.1, 4.1,
 4.1, 3.2, 3.2, 4.1, 3.2, 3.2, 4.1, 4.5, 4.1, 4.1, 167.9, 75.24,
 44.03, 23.69, 19.06, 15.72, 11.42, 8.32, 6.31, 4.9, 6.31, 4.9,
 4.9, 4.1, 4.1, 3.2, 4.1, 4.1, 4.1, 90.18, 102.45, 39.99, 29.73,
 8.32, 21.36, 21.36, 21.36, 12.48, 11.42, 12.48, 11.42, 12.48,
 14.63, 14.63, 15.72, 23.69, 28.5, 29.73, 33.49, 29.73, 23.69,
 21.36, 6.31, 16.82, 15.72, 15.72, 15.72, 15.72, 16.82, 20.2,
 20.2, 21.36, 21.36, 26.07, 28.5, 29.73, 33.49, 29.73, 33.49,
 34.77, 26.07, 26.07, 23.69, 23.69, 26.07, 21.36, 23.69, 23.69,
 23.69, 24.88, 21.36, 20.2, 16.82, 19.06, 20.2, 21.36, 20.2, 20.2,
 24.88, 23.69, 26.07, 29.73, 23.69, 24.88, 29.73, 36.05, 33.49,
 34.77, 28.5, 28.5, 26.07, 153, 70.47, 58.26, 81.77, 36.05, 39.99,
 30.98, 33.49, 28.5, 28.5, 33.49, 29.73, 28.5, 24.88, 30.98, 38.67,
 30.98, 50.01, 65.8, 51.01, 38.67, 34.77, 29.73, 29.73, 33.49,
 30.98, 30.98, 30.98, 33.49, 34.77, 33.49, 30.98, 88.48, 14.63,
 8.32,