Re: [R] Replace the value with 1 and 0

2015-02-26 Thread Göran Broström
On 2015-02-26 00:33, JS Huang wrote: Hi, Here is an implementation. More data are added. An extra column hasRain is added instead of replacing column Amount. rain Year Month Day Amount 1 1950 1 10.0 2 1950 1 2 35.5 3 1950 1 3 17.8 4 1950 1 4

Re: [R] Replace the value with 1 and 0

2015-02-25 Thread JS Huang
Hi, Here is an implementation. More data are added. An extra column hasRain is added instead of replacing column Amount. rain Year Month Day Amount 1 1950 1 10.0 2 1950 1 2 35.5 3 1950 1 3 17.8 4 1950 1 4 24.5 5 1950 1 5 12.3 6 1950 1

Re: [R] Replace the value with 1 and 0

2015-02-25 Thread Peter Alspach
Tena koe Something like: set.seed(153) # Create some (unrealistic) rainfall data yourData - data.frame(year=rep(1950:1954, each=10), month=rep(rep(1:2, each=5), 5), rain=sample(0:1, 50, replace=TRUE)*round(rnorm(50, 20, 2), 1)) tapply(yourData$rain0, yourData[,c('year','month')], sum) will

Re: [R] Replace the value with 1 and 0

2015-02-25 Thread Clint Bowman
or: with(yourData,table(year,month,yourData[[rain]]0)) Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:

[R] Replace the value with 1 and 0

2015-02-25 Thread smart hendsome
Hi everyone, I have this kind of rainfall dataset:    Year Month Day Amount 1  1950 1   1    0.0 2  1950 1   2   35.5 3  1950 1   3   17.8 4  1950 1   4   24.5 5  1950 1   5   12.3 6  1950 1   6   11.5 7  1950 1   7    5.7 8  1950 1   8   13.2 9  1950 1   9