Dear Jim,
Thanks a lot for your support.
Take care.
Md
On Wed, Aug 5, 2020 at 1:06 PM Jim Lemon wrote:
> Hi Md,
> I think the errors are that you forgot to initialize "m", calculated
> the mean outside the loops and forgot the final brace:
>
> m<-rep(0,44)
> for(i in 1975:2017) {
> for(j in
Dear Rui,
Thank you for your nice help.
Take care and be safe.
Md
On Tue, Aug 4, 2020 at 10:45 PM Rui Barradas wrote:
> Hello,
>
> Please keep cc-ing the list R-help is threaded and questions and answers
> might be of help to others in the future.
>
> As for the question, see if the following
Hi Md,
I think the errors are that you forgot to initialize "m", calculated
the mean outside the loops and forgot the final brace:
m<-rep(0,44)
for(i in 1975:2017) {
for(j in 1:44) {
mddat2[j]<-mddat[mddat$Year == i & mddat$Month >= 7 |
mddat$Year == (i+1) & mddat$Month <= 6,]
m[j]=m
Hello,
Please keep cc-ing the list R-help is threaded and questions and answers
might be of help to others in the future.
As for the question, see if the following code does what you want.
First, create a logical index i of the months between 7 and 3 and use
that index to subset the original
Your problem is in the subset operation. You have asked for a value of
month greater or equal to 7 and less than or equal to 6. You probably
got an error message that told you that the data were of length zero
or something similar. If you check the result of that statement:
> mddat$month >= 7 & md
Hello,
And here is another way, with aggregate.
Make up test data.
set.seed(2020)
df1 <- expand.grid(Year = 2000:2018, Month = 1:12)
df1 <- df1[order(df1$Year),]
df1$Value <- sample(20:30, nrow(df1), TRUE)
head(df1)
#Use subset to keep only the relevant months
aggregate(Value ~ Year, data = s
On 2020-08-03 21:11 +1000, Jim Lemon wrote:
> On Mon, Aug 3, 2020 at 8:52 PM Md. Moyazzem Hossain
> wrote:
> >
> > Hi,
> >
> > I have a dataset having monthly
> > observations (from January to
> > December) over a period of time like
> > (2000 to 2018). Now, I am trying to
> > take an average
Hi Md,
One way is to form a subset of your data, then calculate the means by year:
# assume your data is named mddat
mddat2<-mddat[mddat$month < 7,]
jan2jun<-by(mddat2$value,mddat2$year,mean)
Jim
On Mon, Aug 3, 2020 at 8:52 PM Md. Moyazzem Hossain wrote:
>
> Hi,
>
> I have a dataset having mont
ot; "58" "59" "60"
[61] "61" "62" "63" "64" "65" "66" "67" "68" "69" "70" "71" "72"
[73] "73" "74" "75"
, 2013 12:52 PM
Subject: Re: [R] arrange data
it is ok, but I want for all rows not only for 2, like in my example.
Thank you very much!
On 6 April 2013 19:47, arun wrote:
>
>Hi,
>Try this:
>#dat1 is dataset
>indx<-apply(dat1,2,function(x) head(which(!is.na(x)),2))
>re
Hi,
Try this:
#dat1 is dataset
indx<-apply(dat1,2,function(x) head(which(!is.na(x)),2))
res<-as.data.frame(sapply(seq_len(ncol(indx)),function(i) dat2[indx[,i],i]))
colnames(res)<- colnames(dat1)
res
# 1B 2B 4B 1A 2A 4A 5B 5A C31A C31B C34A C34B C35A
#1 2.518 2.357
If you want to reorder the column names of your data frame, try (it would
have been nice if you provided a subset of your data with 'dput'):
# create the order of the new columns
indx <- order(substring(colnnames(df), 3, 3)
, substring(colnames(df), 1, 2)
)
df <
On Apr 6, 2013, at 7:28 AM, catalin roibu wrote:
> Hello all!
> I have a problem to arrange data in another form. My initial data is like
> this:
> 'data.frame': 421 obs. of 58 variables:
> $ 01A: num NA NA NA NA NA NA NA NA NA NA ...
> $ 01B: num NA NA NA NA NA NA NA NA NA NA ...
> $ 03A: num
om: Roslina Zakaria
>To: Felipe Carrillo
>Sent: Sunday, November 11, 2012 10:56 PM
>Subject: Re: [R] arrange data
>
>
>Thank you so much Felipe, I'll try your suggestion.
>
>
>From: Felipe Carrillo
>To: Roslina Zakaria ; "r-help@r-project.org"
HI,
I think it would be better to store this as a list.
For example:
list1<- list(kuantan.dt[kuantan.dt[,2]==11,],kuantan.dt[kuantan.dt[,2]==12,])
If you wanted to delete 31 December and do column bind:
res<-cbind(kuantan.dt[kuantan.dt[,2]==11,], kuantan.dt[kuantan.dt[,2]==12 &
kuantan.dt[,3]
Something like this...untested
I think cbind recicles the last value(31) since nov and dec are of different
length
nov <- kuantan.dt[(kuantan.dt$Bulan >=11);nov
dec <- kuantan.dt[(kuantan.dt$Bulan >=12);dec
both <- cbind(nov,dec)
# get the first 30 records
both <- head(both,30);both
Felipe D. Ca
1006
#5 99 2 941
#6 0 2 1075A.K.
- Original Message -
From: Rui Barradas
To: arun
Cc: Roslina Zakaria ; R help
Sent: Saturday, October 6, 2012 7:22 AM
Subject: Re: [R] arrange data
Hello,
Using Arun's data example, instead of creating a factor "convert&
Hello,
Using Arun's data example, instead of creating a factor "convert" to 4
digits years.
set.seed(1)
dat1 <- data.frame(Tahun=rep(c(98:99,00),each=36),
Bahun=rep(rep(1:12,times=3),each=3),
x=sample(1:500,108,replace=TRUE))
dat2 <- dat1 # operate on a copy
dat2$Tahu
Hi,
I hope this helps you.
I created a small dataset: 3 replications per month for 1998:2000.
set.seed(1)
dat1<-data.frame(Tahun=rep(c(98:99,00),each=36),Bahun=rep(rep(1:12,times=3),each=3),
x=sample(1:500,108,replace=TRUE))
dat2<-within(dat1,{Tahun<-factor(Tahun,levels=c(98,99,0))})
agg_dt
Here is one way. Suppose your data frame is called 'dat'.
o <- with(dat, order(as.Date(paste(year, month, day, sep="-"
newDat <- dat[o, c("year", "month", "day", "rain")]
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Rosl
20 matches
Mail list logo