similar to: Create new data frame with conditional sums

Displaying 20 results from an estimated 300 matches similar to: "Create new data frame with conditional sums"

2023 Oct 15
2
Create new data frame with conditional sums
Under the hood, sapply() is also a loop (at the interpreted level). As is lapply(), etc. -- Bert On Sun, Oct 15, 2023 at 2:34?AM Jason Stout, M.D. <jason.stout at duke.edu> wrote: > > That's very helpful and instructive, thank you! > > Jason Stout, MD, MHS > Box 102359-DUMC > Durham, NC 27710 > FAX 919-681-7494 > ________________________________ > From: John
2023 Oct 14
2
Create new data frame with conditional sums
Well, here's one way to do it: (dat is your example data frame) Cutoff <- seq(0, .15, .01) Pop <- with(dat, sapply(Cutoff, \(p)sum(Totpop[Pct >= p]))) I think there must be a more efficient way to do it with cumsum(), though. Cheers, Bert On Sat, Oct 14, 2023 at 12:53?AM Jason Stout, M.D. <jason.stout at duke.edu> wrote: > > This seems like it should be simple but I
2023 Oct 13
1
Create new data frame with conditional sums
This seems like it should be simple but I can't get it to work properly. I'm starting with a data frame like this: Tract Pct Totpop 1 0.05 4000 2 0.03 3500 3 0.01 4500 4 0.12 4100 5 0.21 3900 6 0.04 4250 7 0.07 5100 8 0.09
2023 Oct 16
1
Create new data frame with conditional sums
Dear Jason, The code could look something like: dummyData = data.frame(Tract=seq(1, 10, by=1), ?? ?Pct = c(0.05,0.03,0.01,0.12,0.21,0.04,0.07,0.09,0.06,0.03), ?? ?Totpop = c(4000,3500,4500,4100,3900,4250,5100,4700,4950,4800)) # Define the cutoffs # - allow for duplicate entries; by = 0.03; # by = 0.01; cutoffs <- seq(0, 0.20, by = by) # Create a new column with cutoffs dummyData$Cutoff
2023 Oct 16
1
Create new data frame with conditional sums
If one makes the reasonable assumption that Pct is much larger than Cutoff, sorting Cutoff is the expensive part e.g O(nlog2(n) for Quicksort (n = length Cutoff). I believe looping is O(n^2). Jeff's approach using findInterval may be faster. Of course implementation details matter. -- Bert On Mon, Oct 16, 2023 at 4:41?AM Leonard Mada <leo.mada at syonic.eu> wrote: > > Dear
2023 Oct 15
1
Create new data frame with conditional sums
Dear Jason, I do not think that the solution based on aggregate offered by GPT was correct. That quasi-solution only aggregates for every individual level. As I understand, you want the cumulative sum. The idea was proposed by Bert; you need only to sort first based on the cutoff (e.g. using an ordered factor). And then only extract the last value for each level. If Pct is unique, than you
2019 Feb 19
2
Cambiar el formato de datos
Después del "gather()" puedes hacer un "arrange()" que es una ordenación. Y dentro de "arrange()" le indicas la variable por la que ordenas (no hacen falta comillas)... Lo ordenará alfabéticamente. Saludos, Carlos Ortega www.qualityexcellence.es El mar., 19 feb. 2019 a las 13:47, Antonio Rodriguez Andres (< antoniorodriguezandres70 en gmail.com>) escribió:
2012 Sep 24
1
Adding textbox to multiple panels in lattice
Dear R-users, I am trying to add some text in a textbox to all panels in the following example file. Using the panel-function, I can add a white rectangle with panel.rect but then I have to fit in the text into the box by hand and it will not automatically be centered. Does anyone know how to add the text centered with a white box around it automatically? Is there something like panel.textbox for
2019 Feb 19
2
Cambiar el formato de datos
> gather(pobla, key = year, value = totpop, year60:year63) Country year totpop 1 Afghanistan year60 8996351 2 Albania year60 1608800 3 Algeria year60 11124888 4 Andorra year60 13411 Gracias Carlos Antonio On Tue, 19 Feb 2019 at 12:54, Carlos Ortega <cof en qualityexcellence.es> wrote: > Sí, tienes varias formas. > > Mira la función
2013 Apr 25
1
Assigning a variable value based on multiple columns
Hi All, I'm hoping someone can help me with a relatively simple problem. Take the following dataset: ID Diabetes ESRD HIV Contact 1 0 0 NA 0 2 1 0 NA 0 3 NA 1 0 0 4 0 NA 0 1 5 1 1 1 0 I want to generate a
2011 Sep 10
2
[Bug 937] ssh2 pubkey auth broken by user:style syntax
https://bugzilla.mindrot.org/show_bug.cgi?id=937 Patric Stout <patric.stout at gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |patric.stout at gmail.com --- Comment #1 from Patric Stout <patric.stout at gmail.com> 2011-09-10
2019 Feb 19
2
Cambiar el formato de datos
Estimados miembros de la comunidad de R Tengo el siguiente formato en un fichero csv que corresponde a datos de la población para un conjunto de países y para un rango amplio de años. Pais 1960 1961 1962 1963 Albania vvvvv vvvv Algeria vvvvv vvvv Me gustaría pasarlo a la siguiente forma Pais Año Poblacion Albania 1960 vvv Albania 1961 vvvv Albania
1998 Jan 06
0
R-beta: losing attributes in binary ops
Thanks to Thomas Lumley for the very quick fix of the NextMethod(.Generic) bug. The patch enclosed in his message to r-help fixed that problem nicely. But..., I've got another one. x <- 1:4 attr(x,"foo") <- "bar" attributes(x < 4) returns NULL. The "foo" attribute has been lost in the "x < 4" operation. The blue book says that the
2006 Aug 24
2
FreeNx for 64bit Kernel
Could some one guide me from where I can get freenx rpms and its dependencies (nx) for 64bit kernel? I have goggled quite a lot but did not see nx. Rpm for 64 bit. Thanks Rajeev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.centos.org/pipermail/centos/attachments/20060824/43d97203/attachment-0002.html>
2024 Dec 06
1
Sum by group
I have population data (?totpopE?) at the census tract level (?GEOID?), which are nested within Precincts (?Precinct?). Please see below my data structure. I used the code to sum population data per precinct: inters <- inters %>% group_by(Precinct) %>% mutate(TotalPop = sum(totpopE) ) However, said code produced too large sums because each census tract (?GEOID?) has multiple
2007 Nov 30
1
memory leak?
I have a client I''m testing where the puppetd process grows slowly (over a few days) to the point where it exceeds 100MB. This triggers an alert and we restart the daemon, but I''m curious whether anyone has noticed similar behavior. Details are: Server: CentOS 4.5 x86 (on VMWare Server guest) RPM install from dlutter repo (puppet-0.23.2-1.el4) The only thing I can
2008 Feb 09
1
Problem with fitdistr function
Hello, I am using fitdistr function for parameter estimation. When I use fd<-fitdistr(V2,"gamma") I get following error: Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, : initial value in 'vmmin' is not finite fd<-fitdistr(V2,"weibull") Error in optim(x = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, :
2005 Feb 24
3
High capacity voicemail
Hi, Does anybody has experience with high capacity PSTN voicemail and asterisk, running more then 5k mailboxes for PSTN users ? How many mailboxes can I serve with 4xE1 card if we assume that we have enough harddrive capacity. What would be server requirements. Would the CPU load be the same when storing voicemails in gsm format as compresing to gsm for ip calls ? Any hints would be greatly
2006 Oct 18
5
What is exactly PuppetShow?
... or better, what is intended to be? I''ve seen references to PuppetShow in IRC, mailing lists and documentation, but still have no clear idea of what it is. Is it just a reporting tool? Will you be able to create manifests or configure nodes from it? Thanks, best regards Jose _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com
2007 Mar 07
8
Writing definitions to support changing defaults
What is the right way to write definition so that defaults can be overriden? $puppetdir = "puppet://$server/files" define remotefile($source, $owner = "root", $group = "root", $mode = 0644, $backup = false, $recurse = false) { file { $name: mode => $mode, owner => $owner, group => $group, backup => $backup,