Displaying 20 results from an estimated 9000 matches similar to: "Finding Highest value in groups"
2016 Apr 22
2
Finding Highest value in groups
Hi
I have two columns in data frame. First column is based on "ID" assigned to each group of my data (similar ID depicts one group). From second column, I want to identify highest value among each group and want to assign the same ID to that highest value.
Right now the data looks like:
ID Value
1 0.69
1 0.31
2 0.01
2 0.99
3 1.00
4 NA
4
2016 Apr 22
0
Finding Highest value in groups
Assuming your dataframe is in a variable x:
> require(dplyr)
> x %>% group_by(ID) %>% summarise(maxVal = max(Value,na.rm=TRUE))
On Fri, 2016-04-22 at 13:51 +0000, Saba Sehrish via R-help wrote:
> Hi
>
>
> I have two columns in data frame. First column is based on "ID" assigned to each group of my data (similar ID depicts one group). From second column, I
2016 Apr 22
0
Finding Highest value in groups
idvalues <- data.frame (ID = c(1, 1, 2, 2, 3, 4, 4, 4, 5, 5),
Value = c(0.69, 0.31, 0.01, 0.99, 1.00, NA, 0,1, 0.5, 0.5))
aggregate(Value~ID, data=idvalues, max)
ID Value
1 1 0.69
2 2 0.99
3 3 1.00
4 4 1.00
5 5 0.50
--
Best,
GG
[[alternative HTML version deleted]]
2010 Mar 31
1
Weird R behaviour?
Dear list,
I have observed a weird behaviour from R --- apologies if I am missing
something obvious!
df3f826f28
df3f826f28
Say you type in R:
>c.preec <- 10074
>c.gd <- 2200
>p1 <- .2
>c.neo <- p1*9451 + (1-p1)*3883
>n.preec <- 3710
>n.gd <- 2650
>n.neo <- 2120
>n.pcos <- 53000
>unit.met <- 94
>cost.met <- 94*n.pcos
>effect <-
2016 Apr 30
1
selection columns by type, ie, numeric
My? thanks to Bill Dunlap and??Giorgio Garziano for? their help.?? It is greatly appreciated.? I works so well, wow.
Carl Sutton CPA
[[alternative HTML version deleted]]
2008 Jun 18
4
inverse cumsum
I've a matrix like this:
1985 1.38 1.27 1.84 2.10 0.59 3.47
1986 1.05 1.13 1.21 1.54 0.21 2.14
1987 1.33 1.21 1.77 1.44 0.27 2.85
1988 1.86 1.06 2.33 2.14 0.55 1.40
1989 2.10 0.65 2.74 2.43 1.19 1.45
1990 1.55 0.00 1.59 1.94 0.99 2.14
1991 0.92
2004 Apr 28
3
Possible bug in foreign library import of Stata datasets
Concerning this article, Christopher Zorn, "Generalized Estimating
Equation Models for Correlated Data: A Review with Applications." 2001.
American Journal of Political Science 45(April):470-90.
The author very kindly provides data for replication on his web page:
http://www.emory.edu/POLS/zorn/Data/GEE.zip.
I've been comparing the Professor Zorn's results obtained with
2013 May 23
1
sample(c(0, 1)...) vs. rbinom
Greetings.? My wife is teaching an introductory stat class at UC Davis.? The
class emphasizes the use of simulations, rather than mathematics, to get
insight into statistics, and R is the mandated tool.?? A student in the class
recently inquired about different approaches to sampling from a binomial
distribution.? I've appended some code that exhibits the idea, the gist of
which is that using
2003 Apr 11
2
princomp with not non-negative definite correlation matrix
$ R --version
R 1.6.1 (2002-11-01).
So I would like to perform principal components analysis on a 16X16
correlation matrix, [princomp(cov.mat=x) where x is correlation matrix],
the problem is princomp complains that it is not non-negative definite.
I called eigen() on the correlation matrix and found that one of the
eigenvectors is close to zero & negative (-0.001832311). Is there any
way
2006 Jul 08
1
KhmaladzeTest
Hello. I am a beginer in R and I can not implement the KhmaladzeTest in the following command. Please help me!!!!!!!!!!!
PD: I attach thw results and the messages of the R program
R : Copyright 2006, The R Foundation for Statistical Computing
Version 2.3.1 (2006-06-01)
ISBN 3-900051-07-0
R es un software libre y viene sin GARANTIA ALGUNA.
Usted puede redistribuirlo bajo ciertas
2008 Jan 26
1
Read stata file from internet?
Dear R-helpers,
I would like to have my students read into R an online Stata dataset: 'http://www.stat.ucla.edu/projects/datasets/risk_project.dta'
I was able to read it into R after downloading it and converting it
with StatTransfer (http://www.stattransfer.com/).
Here is what happens when I use read.dta() as I would use read.table():
> require(foreign)
> risk2 <-
2011 Aug 17
2
dotchart vs. dotplot ... groups
I'm trying to create a dotplot with some grouping.
I've been able to create what I want using dotchart (basic graphics), but can't quite get it using dotplot (lattice). I prefer to use lattice (or ggplot2) because I think it's a bit easier to control some other aspects of the plot appearance.
Basically, w/ lattice I've not been able to get the y-axis label to include the
2017 Jun 29
0
Different date formats in one column
I doubt your actual file looks like the mess that made it to my email
software (below) because you posted HTML-format email. Read the Posting
Guide, and in particular figure out how to send plain text email.
You might try the "anytime" contributed package, though I suspect it too
will choke on your mess. Otherwise, that will pretty much leave only a
brute-force series of regular
2017 Jun 29
1
Different date formats in one column
Thanks Jeff. This is a nice way of solving this problem. What about the cases with 0015-02-21?Many thanks.?Best,Farnoosh
On Wednesday, June 28, 2017 10:49 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:
I doubt your actual file looks like the mess that made it to my email
software (below) because you posted HTML-format email. Read the Posting
Guide, and in particular
2007 Jul 30
1
correlation and matrix
Dear everyone,
I am new in R and I've got difficulties in realizing the following
tasks:
-I have variables (factors) with different numbers of levels, either 1,
2 or 3.
-I have a matrix containing these 204 factors and I have to correlate
them by groups of 4 variables.
-I have to delete the factors just having one level ( because when
correlating one-level factors, the output is NA)
here
2017 Sep 18
1
Data arrangement for PLSDA using the ropls package
Hello,
I would like to do a partial least square discriminant analysis (PLSDA) in R using the package "ropls"
Which is in R available via the R command :
source("https://bioconductor.org/biocLite.R")
I try to do a PLSDA to illustrate the impact of two genders (AP,C) on 5 compounds measured in persons (samples) should be illustrated. When I try to do a PLSDA I get the warning
2018 Mar 22
1
exporting data to stata
On Thu, Mar 22, 2018 at 4:52 AM, Raja, Dr. Edwin Amalraj
<amalraj.raja at abdn.ac.uk> wrote:
> Hi ,
>
> library(foreign)
> write.dta(data1, "data1.dta")
>
> should work.
I don't think so:
> library(foreign)
> example(svydesign)
> write.dta(dstrat, "~/Downloads/foo.dta")
Error in write.dta(dstrat, "~/Downloads/foo.dta") :
The
2010 Jun 21
1
survfit function - event information???
Hi all!
I am trying to extract output information from the survfit function in order
to generate a matrix of select output for multiple factors.
Specifically, I am interested in extracting the number of events (in the
output below: 106, 2, 3). The variable names represented in my function
(ee) are shown below, but none of those variables correspond to the column
of events as shown in the output.
2005 Jun 06
3
write.dta limits
Hope everyone id doing great ..
Just need some clarification over the limit of write.dta. I have some
coauthors that use stata and I need to send them my data in .dta format.
the data.frame is 41706x229 and I get the following
Error in write.dta(Panel, file = "STATADATA/Panel.dta", version = 7) :
a binary write error occured
Once I subset the data everything works out fine. my
2011 Nov 08
2
compare linear regressions
Hi,
I'm trying to compare two linear regressions. I'm using the
following approach:
##################
xx<-1:100
df1 <- data.frame(x = xx, y = xx * 2 + 30 + rnorm(n=length(xx),sd=10), g = 1)
df2 <- data.frame(x = xx, y = xx * 4 + 9 + rnorm(n=length(xx),sd=10), g = 2)
dta <- rbind(df1, df2)
dta$g <- factor(dta$g)