Re: [R] The output of script is hidden in console

2010-01-06 Thread Noli Sicad
What output are you expecting? Is a graph? If it is, look for
Rplots.pdf in your data directory. Noli

On 1/6/10, Uwe Ligges lig...@statistik.tu-dortmund.de wrote:


 On 06.01.2010 02:56, Noli Sicad wrote:
 If you are using windows, In windows console.

 Rgui.exe filename.R-The command does not work at all.

 You have open Rgui.exe first, retrieve filename.R then run the script.


 I fear this does not answer the question.


 Noli

 On 1/5/10, vtvdungvtvdung.in...@yahoo.com  wrote:

 Hi everyone,
 I execute a script with
 source(filename)
 The script has effect but i don't see the output on console screen.Why?

 You have not printed the ouput. Either do that explicitly or via the
 argument print.eval=TRUE in source() which should have been revealed by
 reading ?source.

 Best wishes,
 Uwe Ligges


 I'm a newbie. Thanks :handshake:

 __
 R-help@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.


__
R-help@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.


Re: [R] plot

2010-01-06 Thread Noli Sicad
Have a look on these R graphs.

http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html
http://www.statmethods.net/graphs/line.html
http://addictedtor.free.fr/graphiques/allgraph.php

Noli

On 1/7/10, lse1986 sam_eden1...@yahoo.co.uk wrote:

 Hey guys,

 any chance i can do some plots similar to these in R?
 http://i.imagehost.org/0785/Untitled_3.jpg
 --
 View this message in context:
 http://n4.nabble.com/plot-tp1008481p1008481.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@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.


__
R-help@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.


Re: [R] Tranpose and Aggregate Data - now Reshape - cast

2010-01-05 Thread Noli Sicad
library(reshape)

names(harvest.dat) = c(CROP_ID, CROPTYPE, PERIOD,CUT_AGE)

harvest -cast(harvest.dat, CROP_ID + CROPTYPE ~ PERIOD)

It seems that I am getting the frequencies instead of the individual values.

Output
~
   CROP_ID CROPTYPE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
1 1  OTO 2 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0
2 1 SORI 4 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0
3 2  OTO 0 6 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0
4 2 SORI 0 3 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0
5 2 SORM 0 1 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0
6 3  OTO 0 0 2 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0
7 3 OTRM 0 0 1 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0
8 3 SORI 0 0 1 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0
9 3 SORM 0 0 1 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0
~


Desired table

CROP_ID CROPTYPE P1P2P3P4   P5P6
 P7  P8P9P10
 83  SORI31
 84  SORI32
 85  SORI33
 86  SORI34
 82  SORI28
 83  SORI29
 84  SORI30
 93  SORM35
 62  OTRM30
 82  SORI27
 3   SORM35
 82  SORI26
 4   SORM34
 5   OTRI25
 5   OTRM29
 5   SORM32
 5   SORM33
 5   SORM35
 6   OTRI22
 6   OTRI23
 6   OTRI24
 6   OTRM26
 6   OTRM27
 6   OTRM28
 7   OTRM26
 8   OTRM26

How do I do this properly.

Thanks in advance. Noli

__
R-help@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.


[R] Data Frame Transpose

2010-01-05 Thread Noli Sicad
Hi,

forests - read.csv(C:\\Down2\\R_forestmgt\\forest_cut-Age.csv)

m - forests

fn - function(x) {
  y - t(x[,2])
  data.frame( Croptype=x[1,1], Period =x[1,2], name=colnames(x)[2],
x01=y[,1])x01=y[,1], x02=y[,2], x03=y[,3] } ---Problem
here

m - do.call( rbind, lapply(split(m,list(m$Period,m$Croptype)),fn) )

m - m[order(m$Period,m$Croptype),]


I think I having a problem in here: x01=y[,1])x01=y[,1], x02=y[,2],
x03=y[,3]. how to address with my data. I have variable Period.

based on this http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg09264.html

P_ID Croptype  Period  Ini_Age  Area_Cut
83  SORI1   31  528.2465512
84  SORI1   32  74.55179899
85  SORI1   33  72.45778618
86  SORI1   34  139.5272947
82  SORI2   28  1.711642933
83  SORI2   29  2.50071
84  SORI2   30  432.5139327
93  ORM2   35  316.8422545
62  OTRM3   30  64.60526438
82  SORI3   27  26.93674606
3   SORM3   35  223.3658345
82  SORI4   26  2.50071
4   SORM4   34  1008.643
5   OTRI5   25  32.42603214
5   OTRM5   29  65.9031344
5   SORM5   32  223.1489321
5   SORM5   33  72.59203041
5   SORM5   35  222.8402746
6   OTRI6   22  2.49851
6   OTRI6   23  3.374626509
6   OTRI6   24  96.13462257
6   OTRM6   26  830.7463641
6   OTRM6   27  731.6228643
6   OTRM6   28  16.3519762
7   OTRM7   26  1636.5693
8   OTRM8   26  553.0050146
9   OTRM9   26  894.414033
10  OTRM10  24  38.72597099
10  OTRM10  25  308.6452707
10  OTRM10  26  786.1761969
10  SORM10  31  235.8360136

To this.

P_ID Croptype P1P2P3P4   P5P6P7
  P8P9P10
83  SORI31
84  SORI32
85  SORI33
86  SORI34
82  SORI28
83  SORI29
84  SORI30
93  SORM35
62  OTRM30
82  SORI27
3   SORM35
82  SORI26
4   SORM34
5   OTRI25
5   OTRM29
5   SORM32
5   SORM33
5   SORM35
6   OTRI22
6   OTRI23
6   OTRI24
6   OTRM26
6   OTRM27
6   OTRM28
7   OTRM26
8   OTRM26
9   OTRM

Thanks in advance. Noli

__
R-help@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.


Re: [R] The output of script is hidden in console

2010-01-05 Thread Noli Sicad
If you are using windows, In windows console.

Rgui.exe filename.R -The command does not work at all.

You have open Rgui.exe first, retrieve filename.R then run the script.

Noli

On 1/5/10, vtvdung vtvdung.in...@yahoo.com wrote:

 Hi everyone,
 I execute a script with
 source(filename)
 The script has effect but i don't see the output on console screen.Why?
 I'm a newbie. Thanks :handshake:

__
R-help@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.


Re: [R] Data Frame Transpose

2010-01-05 Thread Noli Sicad
Hi John

Thanks for your reply. I think I was posting properly the problem.

Here are the error, R script and console errors below.

Thanks. Noli

~~~
The error:
~~
Error in data.frame(CROP_ID = x[1, 1], CROPTYPE = x[1, 2], name =
colnames(x)[4:5],  :
 subscript out of bounds
~~~

I have a dynamic subscripts for the Period, as result of linear
programming (LP) model run. How I generalise this line. Right now it
has 3 index only.

x01=y[,1], x02=y[,2], x03=y[,3])

This is sample the data.

PERIOD
1
1
1
1
2
2
2
2
3
3
3
4
4
5
5
5
5
5
6
6
6
6
6
6
7
8
9
10
10
10
10



R  script:

harvest.dat - read.dbf('C:\\Down2\\R_forestmgt\\Carbon\\forest_cut_m.dbf')

names(harvest.dat) = c(CROP_ID, CROPTYPE, PERIOD,CUT_AGE, AREA_CUT)

# Transpose 5 columns

fn - function(x) {
 y - t(x[,4:5])
 data.frame( CROP_ID=x[1,1], CROPTYPE=x[1,2], name=colnames(x)[4:5],
x01=y[,1], x02=y[,2], x03=y[,3])
 }

harvest.dat - do.call( rbind,
lapply(split(harvest.dat,list(harvest.dat$CROP_ID,harvest.dat$CROPTYPE)),fn)
)

write.csv(harvest.dat, forest_cut3.csv)
 ~

Scite console with r package
~
Rscript --vanilla --slave 
C:\Down2\R_forestmgt\Carbon\ForestCarbon_1_F_Clean7_transpose.R
[1] C:/Down2/R_forestmgt/Carbon
Loading required package: foreign
Loading required package: sp
Loading required package: methods
Loading required package: lattice
Warning messages:
1: package 'maptools' was built under R version 2.10.1
2: package 'foreign' was built under R version 2.10.1
3: package 'sp' was built under R version 2.10.1
Error in data.frame(CROP_ID = x[1, 1], CROPTYPE = x[1, 2], name =
colnames(x)[4:5],  :
 subscript out of bounds
Calls: do.call - lapply - FUN - data.frame
Execution halted
Exit code: 1Time: 2.128
~

__
R-help@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.


[R] Tranpose and Aggregate Data

2010-01-04 Thread Noli Sicad
Hi,

I need to transpose and aggregate the 4th and 5th column of this data
set (below). The period is 1 to 100 years and  some period has 1 entry
as shown in the example below.

Any ideas how to do this. Thanks in advance.

Noli

~~

From:

P_ID CROP  Period  Ini_Age  Area_Cut
83  SORI1   31  528.2465512
84  SORI1   32  74.55179899
85  SORI1   33  72.45778618
86  SORI1   34  139.5272947
82  SORI2   28  1.711642933
83  SORI2   29  2.50071
84  SORI2   30  432.5139327
93  ORM2   35  316.8422545
62  OTRM3   30  64.60526438
82  SORI3   27  26.93674606
3   SORM3   35  223.3658345
82  SORI4   26  2.50071
4   SORM4   34  1008.643
5   OTRI5   25  32.42603214
5   OTRM5   29  65.9031344
5   SORM5   32  223.1489321
5   SORM5   33  72.59203041
5   SORM5   35  222.8402746
6   OTRI6   22  2.49851
6   OTRI6   23  3.374626509
6   OTRI6   24  96.13462257
6   OTRM6   26  830.7463641
6   OTRM6   27  731.6228643
6   OTRM6   28  16.3519762
7   OTRM7   26  1636.5693
8   OTRM8   26  553.0050146
9   OTRM9   26  894.414033
10  OTRM10  24  38.72597099
10  OTRM10  25  308.6452707
10  OTRM10  26  786.1761969
10  SORM10  31  235.8360136

To this.

P_ID CROP P1P2P3P4   P5P6P7
   P8P9P10
83  SORI31
84  SORI32
85  SORI33
86  SORI34
82  SORI28
83  SORI29
84  SORI30
93  SORM35
62  OTRM30
82  SORI27
3   SORM35
82  SORI26
4   SORM34
5   OTRI25
5   OTRM29
5   SORM32
5   SORM33
5   SORM35
6   OTRI22
6   OTRI23
6   OTRI24
6   OTRM26
6   OTRM27
6   OTRM28
7   OTRM26
8   OTRM26
9   OTRM
 26
10  OTRM
 24
10  OTRM
 25
10  OTRM
 26
10  SORM
 31

__
R-help@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.


Re: [R] Tranpose and Aggregate Data

2010-01-04 Thread Noli Sicad
 From:

 P_ID CROP  Period  Ini_Age
CROP_ID CROPTYPEPeriod  Ini_Age
83  SORI   131
84  SORI1   32
85  SORI 1  33
86  SORI 1  34
82  SORI 2  28
83  SORI 2  29
84  SORI 2  30
93  SORM2   35
62  OTRM3   30
82  SORI3   27
3   SORM3   35
82  SORI4   26
4   SORM4   34
5   OTRI5   25
5   OTRM5   29
5   SORM5   32
5   SORM5   33
5   SORM5   35
6   OTRI6   22
6   OTRI6   23
6   OTRI6   24
6   OTRM6   26
6   OTRM6   27
6   OTRM6   28
7   OTRM7   26
8   OTRM8   26
9   OTRM9   26
10  OTRM10  24
10  OTRM10  25
10  OTRM10  26
10  SORM10  31




 To this.

 P_ID CROP P1P2P3P4   P5P6P7
P8P9P10
 83  SORI31
 84  SORI32
 85  SORI33
 86  SORI34
 82  SORI28
 83  SORI29
 84  SORI30
 93  SORM35
 62  OTRM30
 82  SORI27
 3   SORM35
 82  SORI26
 4   SORM34
 5   OTRI25
 5   OTRM29
 5   SORM32
 5   SORM33
 5   SORM35
 6   OTRI22
 6   OTRI23
 6   OTRI24
 6   OTRM26
 6   OTRM27
 6   OTRM28
 7   OTRM26
 8   OTRM26
 9   OTRM
  26
 10  OTRM
  24
 10  OTRM
  25
 10  OTRM
  26
 10  SORM
  31


__
R-help@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.


Re: [R] Tranpose and Aggregate Data

2010-01-04 Thread Noli Sicad
Sorry, the second email is accidently sent. Yes, the Cut Area should
not be included in the data in the first email.  The second email has
a correct data.

Thanks. Noli

__
R-help@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.


Re: [R] Tranpose and Aggregate Data

2010-01-04 Thread Noli Sicad
Schalk,

Thank you very much for this.

Noli


On 1/5/10, Schalk Heunis schalk.heu...@gmail.com wrote:
 Hi

 You can use the reshape package to achieve this.  If you don't have it
 installed, install.packages('reshape').  Then look at ?cast and (possibly)
 ?melt
 HTH!

 Schalk


 On Tue, Jan 5, 2010 at 7:59 AM, Noli Sicad nsi...@gmail.com wrote:

 Hi,

 I need to transpose and aggregate the 4th and 5th column of this data
 set (below). The period is 1 to 100 years and  some period has 1 entry
 as shown in the example below.

 Any ideas how to do this. Thanks in advance.

 Noli

 ~~

 From:

 P_ID CROP  Period  Ini_Age  Area_Cut
 83  SORI1   31  528.2465512
 84  SORI1   32  74.55179899
 85  SORI1   33  72.45778618
 86  SORI1   34  139.5272947
 82  SORI2   28  1.711642933
 83  SORI2   29  2.50071
 84  SORI2   30  432.5139327
 93  ORM2   35  316.8422545
 62  OTRM3   30  64.60526438
 82  SORI3   27  26.93674606
 3   SORM3   35  223.3658345
 82  SORI4   26  2.50071
 4   SORM4   34  1008.643
 5   OTRI5   25  32.42603214
 5   OTRM5   29  65.9031344
 5   SORM5   32  223.1489321
 5   SORM5   33  72.59203041
 5   SORM5   35  222.8402746
 6   OTRI6   22  2.49851
 6   OTRI6   23  3.374626509
 6   OTRI6   24  96.13462257
 6   OTRM6   26  830.7463641
 6   OTRM6   27  731.6228643
 6   OTRM6   28  16.3519762
 7   OTRM7   26  1636.5693
 8   OTRM8   26  553.0050146
 9   OTRM9   26  894.414033
 10  OTRM10  24  38.72597099
 10  OTRM10  25  308.6452707
 10  OTRM10  26  786.1761969
 10  SORM10  31  235.8360136

 To this.

 P_ID CROP P1P2P3P4   P5P6P7
   P8P9P10
 83  SORI31
 84  SORI32
 85  SORI33
 86  SORI34
 82  SORI28
 83  SORI29
 84  SORI30
 93  SORM35
 62  OTRM30
 82  SORI27
 3   SORM35
 82  SORI26
 4   SORM34
 5   OTRI25
 5   OTRM29
 5   SORM32
 5   SORM33
 5   SORM35
 6   OTRI22
 6   OTRI23
 6   OTRI24
 6   OTRM26
 6   OTRM27
 6   OTRM28
 7   OTRM26
 8   OTRM26
 9   OTRM
 26
 10  OTRM
 24
 10  OTRM
 25
 10  OTRM
 26
 10  SORM
 31

 __
 R-help@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.



__
R-help@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.