similar to: function by: order within subsets

Displaying 20 results from an estimated 30000 matches similar to: "function by: order within subsets"

2008 Jun 27
3
cumulative sum of within levels of a dataframe
This one should be easy but it's giving me a hard time mostly because tapply puts the results in a list. I want to calculate the cumulative sum of a variable in a dataframe, but with the accumulation only within each level of a factor. For a very simple example, take: > df <- data.frame(x=c(rep(1,5),rep(2,5),rep(3,5)),fac=gl(3,5,labels=letters[1:3])) > df x fac 1 1 a 2 1 a
2003 Nov 17
4
cumulative distribution functions
hi y'all, I am wondering if there is any special command, function, package, etc to help me doing a cumulative distribution function, with y-scale - probability scale. I tried the help in R and i got the following answers: cumsum(base) Cumulative Sums, Products, and Extremes ecdf(stepfun) Empirical Cumulative Distribution Function cpgram(ts) Plot
2002 Jul 24
4
cumsum and subsets of a data frame?
I have a question about using cumsum on subsets of a data frame. Suppose I have a frame that looks something like this > tmp f x y 1 left 1 0 2 left 2 0 3 left 3 9 4 left 4 10 5 left 5 23 6 left 6 45 7 left 7 13 8 left 8 2 9 left 9 6 10 right 1 10 11 right 2 26 12 right 3 9 13 right 4 50 14 right 5 78 15 right 6 20 16 right 7 7 17 right 8 20 18 right 9 19
2009 Nov 21
1
how to ignore NA when using cumsum WHILE retaining NAs?
I would like to cumulatively sum rows in a matrix, in which each row has 1 NA value, which I do NOT want to treat as 0s. The NAs are placeholders where there is actually no data, which is not the same as a 0. The usual "na.rm=TRUE" does not seem to work with the command cumsum. Is there another way to ignore the NAs or do I need to figure out a different way to do this? Here's an
2009 Aug 11
1
Help on a combinatorial task (lists?)
Hello! I have the following combinatorial problem. Consider the cumulative sums of all permutations of a given weight vector 'w'. I need to know how often weight in a certain position brings the cumulative sums equal or above the given threshold 'q'. In other words, how often each weight is decisive in raising the cumulative sum above 'q'? Here is what I do: w <-
2009 Jun 17
2
cumulative sum in data frame
Dear R-Help List, I have a question about data manipulation. I tried to make code myself but too much for me. I would greatly appreciate your help. I have data set consisting of site (from 1 to N1) and distance and there are several variables (1 to N2) collected from each sampling site. I am interested in looking at cumulative sums of each variable based on site and distance like below. Can
2012 Feb 14
1
cumsum function to determine plankton phenology
Apologies for the empty email earlier! I have species abundance data sampled at a weekly frequency or sometimes monthly depending on the year. The goal is to identify the dates in an annual cycle in which the cumulative abundance of a species reaches some threshold. Here's an example of the data for 1 species over an annual period: "mc_pheno" is the object created from this data:
2009 Nov 21
2
how to ignore NA when using cumsum?
I would like to cumulatively sum rows in a matrix, in which each row has 1 NA value. The usual "na.rm=TRUE" does not seem to work with the command cumsum. Is there another way to ignore the NAs or do I need to figure out a different way to do this? Here's an example matrix of title "proportion": Ntrail Strail NFJD Baldy Onion Crane [1,]
2005 Feb 10
5
Annual cumulative sums from time series
Hello world, I am actually transferring a course in data management for students in biology, geography and agriculture from statistica to R - it works surprisingly well. If anyone is interested in my scratch/notepad (in German language), please see www.hydrology.uni-kiel.de/~schorsch/statistik/statistik_datenauswertung.pdf (pages 40-52) The dataset is:
2013 Mar 26
2
Plot cumulative sums of rainfall per year
Hi @all, I am biting my nails with the following problem: I have a data set of daily rainfall measurements for the last 20 years. What I want to do is calculate the daily cumulative sum of rainfall but only for every year which means that the cumulative sum has to be reset each year. After the calculations I want to plot each year of cumulative rainfall as a separate line in one graph preferably
2009 Jul 28
1
Cumulative row sums, row differences
I tried searching but I couldn't quite find what I was looking for. Here's a dummy data matrix (with row and column labels): > y 0 1 2 3 4 21 3 4 8 5 5 22 3 6 8 6 NA 23 4 5 11 4 3 24 4 2 1 4 6 25 6 4 4 6 6 I can get cumulative row sums as follows: > cy<-t(apply(y,1,cumsum)) > cy 0 1 2 3 4 21 3 7 15 20 25 22 3 9 17 23 NA 23 4 9 20 24 27 24 4 6 7 11 17
2010 Apr 14
5
Running cumulative sums in matrices
Dear R-helpers, I have a huge data-set so need to avoid for loops as much as possible. Can someone think how I can compute the result in the following example (that uses a for-loop) using some version of apply instead (or any other similarly super-efficient function)? example: #Suppose a matrix: m1=cbind(1:5,1:5,1:5) #The aim is to create a new matrix with every column containing the
2009 Nov 11
2
partial cumsum
Hello, I am searching for a function to calculate "partial" cumsums. For example it should calculate the cumulative sums until a NA appears, and restart the cumsum calculation after the NA. this: x <- c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10) should become this: 1 3 6 NA 5 11 18 26 35 45 any ideas? thank you and best regards, stefan
2009 Jul 30
1
rowSums, rowMean and rowCumSums?
Dear list, Don't you think it could be useful to have in R base a function rowCumSums, that compute cumulative sums for each row of a matrix? My implementation of rowCumSums is rowCumSums <- function(x) t(mapply(function(row)cumsum(x[row,]), 1:NROW(x))) I'm sure it can be improved to have other arguments like na.rm or dims. Is there any hope to have this function in R?
2011 Jul 14
2
Add a density line to a cumulative histogram - second try
Hi list, this is my second try for first post on this list (I tried to post via email and nothing appeared in my email-inbox, so now I try to use the nabble-web-interface) - I hope that you will only have to read one post in your inbox! Okay, my question ... I was able to plot a histogram and add the density()-line to this plot. I was able to plot a cumulative form of this histogram. Yet, I was
2004 Jun 11
1
lattice: cumsum and xyplot
I want to display cumulative summary functions with lattice. First I tried to get cumulated data: library(lattice) data(barley) d.cum <- with( barley, by( yield, INDICES=list(site=site,year=year), FUN=cumsum ) ) I got a list of vectors. I tried to get a dataframe which I could use in xyplot. But neither of the following functions led to the goal: d.cum.df1 <-
2011 Nov 26
5
cumsum in 3d arrays
Hello! Is it posible to apply /cumsum()/ along the 3rd dimension of 3D array? Something like matrlab function - /cumsum (*A*,dim)/ which returns the cumulative sum of the elements along the dimension of *A* specified by scalar dim. Thanks in advance ?eljka -- View this message in context: http://r.789695.n4.nabble.com/cumsum-in-3d-arrays-tp4110470p4110470.html Sent from the R help mailing
2006 Aug 13
2
Vector Join
Hi, I'm working on producing a simple cumulative frequency distribution. Thanks to the help of the good people on this list I now have four vectors that I'd like to join/relate into a table. e.g. v1 <- myHistogram$breaks # classes v2 <- myHistogram$counts # freqs v3 <- cumsum(v2) # cumulative freq v4 <- ((v3 / length(myData)) *
2005 Nov 08
3
how to draw cumulative histogram
Hello there, I am using R to plot some cumulative histogram for my data. Please help in this case. Thank you Lisa Wang Princess Margaret Hospital Toronto phone 416 946 4501 ext.4883
2011 Jun 27
7
cumulative incidence plot vs survival plot
Hi, I am wondering if anyone can explain to me if cumulative incidence (CI) is just "1 minus kaplan-Meier survival"? Under what circumstance, you should use cumulative incidence vs KM survival? If the relationship is just CI = 1-survival, then what difference it makes to use one vs. the other? And in R how I can draw a cumulative incidence plot. I know I can make a Kaplan-Meier