Displaying 12 results from an estimated 12 matches for "totpope".
Did you mean:
totpop
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
1
Create new data frame with conditional sums
That's very helpful and instructive, thank you!
Jason Stout, MD, MHS
Box 102359-DUMC
Durham, NC 27710
FAX 919-681-7494
________________________________
From: John Fox <jfox at mcmaster.ca>
Sent: Saturday, October 14, 2023 10:13 AM
To: Jason Stout, M.D. <jason.stout at duke.edu>
Cc: r-help at r-project.org <r-help at r-project.org>
Subject: Re: [R] Create new data frame with
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
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ó:
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
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 produc...
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
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
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