similar to: Finding Highest value in groups

Displaying 20 results from an estimated 6000 matches similar to: "Finding Highest value in groups"

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
1
Finding Highest value in groups
Since the aggregate S3 method for class formula already has got na.action = na.omit, ## S3 method for class 'formula' aggregate(formula, data, FUN, ..., subset, na.action = na.omit) I think that to deal with NA's, it is enough: aggregate(Value~ID, dta, max) Moreover, passing na.rm = FALSE/TRUE is "don't care": aggregate(Value~ID, dta, max, na.rm=FALSE)
2016 Apr 24
2
Inserting a blank row to every other row
Hi I need to insert a blank row after every row in R data frame. I have achieved it through: df[rep(1:nrow(df),1,each=2),] But it inserts a row with name of previous row, while i want a complete blank row without any name/title. Please guide me Regards Saba
2016 Apr 24
3
Dividing rows in groups
Hi I have two data frames as shown below (second one is obtained by aggregating rows of similar IDs in df1.). They both have similar number of columns but rows of df2 are lesser than rows of df1. df1: ID A B 1 1 2 1 0 3 2 5 NA 2 1 3 3 1 4 4 NA NA 4
2016 Apr 24
2
Inserting a blank row to every other row
Well, something like this would work (there may be slicker solutions): > z <- data.frame(a=1:3,b = letters[1:3]) > i <- seq_len(nrow(z)) *2 > z <-rbind(z,z) > z[i, ] <- matrix(NA, nr=nrow(z),nc=ncol(z)) > z a b 1 1 a 2 NA <NA> 3 3 c 4 NA <NA> 5 2 b 6 NA <NA> But I agree with you that there is probably a way to handle the underlying
2016 Apr 24
0
Inserting a blank row to every other row
Hi Saba, I don't know how to do what you want and I also cannot see why. If you describe what you hope to achieve there might be a different solution. Best wishes Ulrik Saba Sehrish via R-help <r-help at r-project.org> schrieb am So., 24. Apr. 2016 14:04: > Hi > > I need to insert a blank row after every row in R data frame. I have > achieved it through: > > >
2016 Apr 10
1
working with unequal rows
Hi I have a data frame with rows specifying companies (codes are assigned to companies) and columns specify months (monthly data). The data is based on male (M) and female (F) information for each month. Following is an example of how my data looks like: 01 02 03 04 001 M M M na 001 F M M M 002 M na F F 003 F F F M 003 F F M na 003 M
2016 Apr 24
0
Inserting a blank row to every other row
Oh, sorry, I just realized that I messed up the indicing. Here is the correct way: > z <- data.frame(a=1:3,b = letters[1:3]) > i <- seq_len(nrow(z)) > z<-z[rep(i,e=2),] > z[2*i, ] <- matrix(NA, nr=nrow(z),nc=ncol(z)) > z Still doubt that this is a good idea, though. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along
2016 Apr 06
1
Descriptive Statistics of time series data
Hi I have four variables and the time series data for each variable consists of values for past 10 years on monthly basis. I want to get descriptive stats for these four variables separately (mean, median, sd, min, max). The data I import to R consists of different columns, where each column gives values for one month of a particular year (e.g. March 31st, 2010). Right now R gives descriptive
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]]
2016 Apr 24
0
Dividing rows in groups
This will handle all the columns; it assumes the ones you want to start with are in column 2 through the end: > library(dplyr) > df1 <- read.table(text = "ID A B + 1 1 2 + 1 0 3 + 2 5 NA + 2 1 3 + 3 1 4 + 4 NA NA + 4 0 1 + 4
2007 Aug 31
3
data frame row manipulation
Hello, struggling with the very basic needs... :( any help appreciated. #using the package doBY #who drinks how much beer per day and therefor cannot calculate rowise maxvals evaluation=data.frame(date=c(1,2,3,4,5,6,7,8,9), name=c("Michael","Steve","Bob", "Michael","Steve","Bob","Michael","Steve","Bob"),
2013 May 15
1
x and y lengths differ
I have a problem with R. I try to compute the confidence interval for my df. When I want to create the plot I have this problem: Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ. I try this code: library(dplR) df.rwi <- detrend(rwl = df, method = "Spline",nyrs=NULL) write.table(df.rwi,file="rwi.txt",quote=FALSE,row.names=TRUE)
2012 Jan 10
1
error in Recursive
Hi I need help in the recursive problem. this is my code #Generate two random Numbers minval=20 maxval=100 cutoffValue=50 optVal<- function(cutoffValue,minval,maxval) { x=runif(2) x=x*cutoffValue for( i in 1:2) { if(x[i] < 30 || x[i] >60) # checking it falls between the range { optVal(cutoffValue,minval,maxval) } } return(x) }
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 <-
2010 Mar 06
2
memory error in for loop
hi, I have been attempting to run this script and am getting some strange results. The script connects to a database and retrieves a series of tables, using sequential sql statements. I have tested all of the sql statements in the PostGreSQL terminal and they all return the desired results. I place each table into a list and run a FOR loop for 'i' in the list. The script generates
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
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
2007 Sep 04
4
Q: selecting a name when it is known as a string
I am 100% certain that there is an easy way to do this, but after experimenting off and on for a couple of days, and searching everywhere I could think of, I haven't been able to find the trick. I have this piece of code: ... attach(d) if (ORDINATE == 'ds') { lo <- loess(percent ~ ncms * ds, d, control=loess.control(trace.hat = 'approximate')) grid <-
2008 Oct 06
3
horizontal boxplot + xlim
Hi there, I get a strange behaviour of a boxplot with the following code. There seems to be a problem with the xlim-parameter. Did I do anything wrong? What else can I do to force the boxplot to have a defined x-range? x <- rnorm(100) boxplot(x, notch=TRUE, xlab=parameter, xlim <- c(-4,4), horizontal = TRUE) Antje