Displaying 20 results from an estimated 30000 matches similar to: "cumsum and subsets of a data frame?"
2011 May 06
1
Cumsum in Lattice Panel Function
I'm trying to create an xyplot with a "groups" argument where the y-variable
is the cumsum of the values stored in the input data frame. I almost have
it, but I can't get it to automatically adjust the y-axis scale. How do I
get the y-axis to automatically scale as it would have if the cumsum values
had been stored in the data frame?
Here is the code I have so far:
2024 Sep 28
1
lattice xyplot with cumsum() function inside
This code gives unexpected result.
library(data.table)
library(lattice)
set.seed(123)
mydt <- data.table(date = seq.Date(as.IDate("2024-01-01"), by = 1,
length.out = 50), xgroup = "A", x = runif(50, 0, 1))
mydt <- rbindlist(list(mydt, data.table(date = mydt$date, xgroup = "B", x = runif(50, 0, 3))))
mydt[, `:=`(xcumsum = cumsum(x)), by = .(xgroup)]
mydt[,
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 <-
2010 Jun 03
1
cumsum function with data frame
Dear list,
I have a problem with the cumsum function.
I have a data frame like the following one
variable Year value
EC01 2005 5
EC01 2006 10
AAO1 2005 2
AAO1 2006 4
what I would like to obtain is
variable Year value cumsum
EC01 2005 5 5
EC01
2006 Jun 07
1
Fw: Help needed using lattice for area plots lpolygon, xyplot.
I am trying to learn how to use the graphics from the lattice package (
and am very new to R).
I am trying to replicate the example plot referenced below, by using the
lattice xyplot & lpolygon to create panels. I get what appears to be the
correct shape of the filled region, but cannot get the position to overlay
properly. I have attempted with various settings of position. ( i.e.
2007 Jan 10
1
roc and lattice
Hello, I am afraid I do not fully understand all intricacies of
programming in lattice plots. In the code below I try to plot an ROC
curve, following R-news 4(1). When I condition on the variable 'group' I
get the error message below, when I plot the curve for all data (i.e., y
~ pred.prob), I get the plot I want. Can someone point out why
conditioning gives that message? Thanks, Ruud
2003 Jan 15
2
[lattice] lines for stripplot (like dotplot) or jitter for dotplot?
I'd like to use stripplot for some plots because I want to use
the jitter parameter. On the other hand, I'd like to use dotplot
because I'd like to have the horizontal lines that it includes.
dotplot doesn't have a jitter option and I'm not having any
success with getting panel.grid(h=-1) with stripplot. Can anyone
show me how to make dotplot-like lines on a stripplot? Or
2003 Dec 31
2
Plot grouped data: How to change x-axis? (nlme)
Hallo!
GENERAL QUESTION:
I'm trying to change the tick marks of the x-axis in a
grouped data plot (nlme).
CONCRETE EXAMPLE:
In the example (see below) I want the x-axis to have
tick marks at 0, 6, 12, 18, 24. How can I do this?
WHAT I TRIED
I tried "normal" methods like axis(...) but this does
not work with this plot. And I also tried xlim=c(0,24)
but the ticks are unchanged and
2002 Jun 27
1
lattice and dates (correcting e-mail formatting glitch - sorry!!)
Hi
I'm fairly new to R and the list, so please take
what I say accordingly!
Far as I can see, strptime gives you a string in some
specified format. In order to do any kind of
numerically-based modelling with that, you need to
obtain a number to work with. One way to do this is by
getting the time with Sys.time() instead and coercing
it to a number using as.integer():
>
2009 Feb 26
1
Incorporating cumsum in for loop
Hello
Hello i have this DF:
> c
CHR_NR
diffdato1 x
1022 10395 1994-05-30 11.0 39 0 1994 1 1
0 0 24 1 1 24
29100 11377 2003-05-22 17.0 24 0 2003 1 1
0 0 15 1
2001 Jul 28
2
lattice and histogram
Hello again folks,
Thanks to all for the advice on getting hold of "grid"
and "lattice". I think I'm getting the hang of it.
This produces very satisfying arrays of histograms.
The typical command I am using is
histogram( ~ DATA.df$X | DATA.df$F, \
type=c("count"), layout=c(5,5) )
Now I'd like to ask a question slightly more subtle
than
2011 Feb 18
2
Scaling Lattice Graphics for tikzDevice
I'm trying to use lattice graphics to produce some small plots for inclusion in a LaTeX file. I want the LaTeX fonts to be used in the plots, but to be scaled down to match the size of the plot. I have written the following code to apply a scaling factor to all the "cex" and "padding" entries in the trellis parameters, but there is still a large white space between the key
2010 Oct 17
2
dpois().......bizarre warning messages
Dear Masters,
I have a question to submit
consider the following script
m<-4.95
obs<-rpois(36,m) # i generate 36 realization from a poisson(m)
hist(obs,freq=F)
curve(dpois(x,m),add=T,col="red") #i wish to overlay on the histogram the
theorical poisson density function
errors are returned saing the x vector doesn't contain integers....
really bizarre i can't give
2012 Aug 01
0
Plotting cumsum data using lattice plots according to date conditioned by name.
I've been playing around with data like the following:
Name Date Hrs
Way, S 2-3-12 8
Nun, B 2-3-12 9
Way, S 2-4-12 7.5
Nun, B 2-4-12 9
Gus, T 2-5-12 8
I've been able to take this into a data.frame and even develop a cumsum
for each of the people
d.cum <- with(data,by(Hrs,
INDICES=list(date=as.POSIXct(Name)),FUN=cumsum))
This gives me a list personnel with an array
2020 Aug 25
1
sum() vs cumsum() implicit type coercion
>>>>> Tomas Kalibera
>>>>> on Tue, 25 Aug 2020 09:29:05 +0200 writes:
> On 8/23/20 5:02 PM, Rory Winston wrote:
>> Hi
>>
>> I noticed a small inconsistency when using sum() vs cumsum()
>>
>> I have a char-based series
>>
>> > tryjpy$long
>>
>> [1]
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:
2020 Aug 23
2
sum() vs cumsum() implicit type coercion
Hi
I noticed a small inconsistency when using sum() vs cumsum()
I have a char-based series
> tryjpy$long
[1] "0.0022" "-0.0002" "-0.0149" "-0.0023" "-0.0342" "-0.0245" "-0.0022"
[8] "0.0003" "-0.0001" "-0.0004" "-0.0036" "-0.001" "-0.0011"
2009 Feb 17
2
cumsum vs. sum
I recently traced a bug of mine to the fact that cumsum(s)[length(s)]
is not always exactly equal to sum(s).
For example,
x<-1/(12:14)
sum(x) - cumsum(x)[3] => 2.8e-17
Floating-point addition is of course not exact, and in particular is
not associative, so there are various possible reasons for this.
Perhaps sum uses clever summing tricks to get more accurate results?
In some
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
2005 May 30
2
trouble with cumsum?
Dear R users,
I am using R version 2.0.1 (2004/11/15) on an i386-pc-mingw32 platform. I
encounter the following problem while using cumsum:
> a <- rep(0.01, 100)
> b <- cumsum(a)
> sum(a) == 1
[1] TRUE
> b[100] == 1
[1] FALSE
Am I missing something? Should cumsum have such an outcome?
Thanks in advance for any clarifications any of you can offer.
Regards,
Makram Talih
--