Thank you very much Mr. Eric and Mr. Bert.
It was really helpful.
Best,
Ani
On Thu, Apr 22, 2021 at 3:36 AM Bert Gunter wrote:
>
> Simpler, and no loops needed per column:
> ## this makes the idea clear
> > x <- 1:12
> > (x %% 12) %/% 3 ## first modulo, then integer divide
> [1] 0 0 1 1 1 2 2
Simpler, and no loops needed per column:
## this makes the idea clear
> x <- 1:12
> (x %% 12) %/% 3 ## first modulo, then integer divide
[1] 0 0 1 1 1 2 2 2 3 3 3 0
## add 1 if you prefer 1 to 4. Better yet, probably, is to turn it into a
factor:
> f <- factor(c("win","spr","sum","fal")[x+1])
> f
Hi Ani,
Before the for loops add the following line
when[,-1] <- when[,-1]%%12 + 1
This changes the month numbering so that Dec becomes 1, Jan becomes 2, etc
Then your for loop does what you want.
HTH,
Eric
On Wed, Apr 21, 2021 at 11:09 AM ani jaya wrote:
> Dear r community,
>
> I have a d
Dear r community,
I have a data frame that shows the month of occurrence of the maximum
value on let say 10 stations in 30 years. I want to make percentages
based on seasons (DJF, MAM, JJA, and SON). I can do that by the code
below but only when we put season by JFM, AMJ, ...(or 123; 456;
789;..)
4 matches
Mail list logo