From: Ebert,Timothy Aaron mailto:teb...@ufl.edu> >
Sent: Thursday, August 25, 2022 11:59 AM
To: avi.e.gr...@gmail.com <mailto:avi.e.gr...@gmail.com>
Cc: R-help@r-project.org <mailto:R-help@r-project.org>
Subject: RE: [R] Getting minimum value of a column according a factor colu
Hi Javad,
In that case, just modify the function to extract the rows with both
the minimum and maximum Q from each station
df1<-read.table(text="Code Y M D Q N O
41003 81 1 19 0.16 7.17 2.5
41003 77 9 22 0.197 6.8 2.2
41003 79 7 28 0.21 4.7 6.2
41005 79 8 17 0.21 5.5 7.2
41005 80 10 30 0
-project.org
Subject: RE: [R] Getting minimum value of a column according a factor column
of a dataframe
My assumption (maybe wrong) was that we needed to keep the other variables.
I want to find the values of Y, M, D, N, and O for the minimum value of Q
within each unique value of Code, keeping the
The order of the rows returned by summarize is controlled by the levels of
the factors given to group_by. If group_by is given character columns
instead of factors, it converts them to factors with the levels being the
sorted unique values of the character columns. Convert you character
columns t
>%
arrange(Code)
dat2<-filter(dat2,Q==MinByCodeQ)
dat2<-arrange(dat2,as.numeric(RN))
-Original Message-
From: R-help On Behalf Of Ebert,Timothy Aaron
Sent: Thursday, August 25, 2022 8:18 AM
To: javad bayat ; Rui Barradas
Cc: R-help@r-project.org
Subject: Re: [R] Getting minimum
at
; Rui Barradas
Cc: R-help@r-project.org
Subject: Re: [R] Getting minimum value of a column according a factor column
of a dataframe
My mistake, I did not change the sort order back to the original order. If
you do not like the additional variables they can be dropped using select()
or dat2[,-c(RN
=MinByCodeQ)
dat2<-arrange(dat2,as.numeric(RN))
-Original Message-
From: R-help On Behalf Of Ebert,Timothy Aaron
Sent: Thursday, August 25, 2022 8:18 AM
To: javad bayat ; Rui Barradas
Cc: R-help@r-project.org
Subject: Re: [R] Getting minimum value of a column according a factor column of
a dat
r(dat2,Q==MinByCodeQ)
Tim
-Original Message-
From: R-help On Behalf Of javad bayat
Sent: Thursday, August 25, 2022 12:56 AM
To: Rui Barradas
Cc: R-help@r-project.org
Subject: Re: [R] Getting minimum value of a column according a factor column of
a dataframe
[External Email]
De
Hello,
OK, what about
res <- lapply(split(df1, df1$Code), \(x) x[which.min(x$Q),])
do.call(rbind, res)
# Code Y M D QNO
# 41003 41003 81 1 19 0.160 7.17 2.50
# 41005 41005 79 8 17 0.210 5.50 7.20
# 41009 41009 79 2 21 0.218 5.56 4.04
# 41017 41017 79 10 20 0.240 5.
: Wednesday, August 24, 2022 3:45 AM
To: R-help@r-project.org
Subject: [R] Getting minimum value of a column according a factor column of
a dataframe
Dear all;
I am trying to get the minimum value of a column based on a factor column of
the same data frame. My data frame is like the below:
Code
--
From: R-help On Behalf Of javad bayat
Sent: Wednesday, August 24, 2022 3:45 AM
To: R-help@r-project.org
Subject: [R] Getting minimum value of a column according a factor column of a
dataframe
[External Email]
Dear all;
I am trying to get the minimum value of a column based on a factor colu
Dear all;
I am trying to get the minimum value of a column based on a factor column
of the same data frame. My data frame is like the below:
Code Y MD
Q
N O
41003 81 1 19 0.16 7.17 2.5
41003 77 9 22 0.197 6.8 2.2
41003 79 7 28 0.
12 matches
Mail list logo