Displaying 20 results from an estimated 2000 matches similar to: "Create new data frame with conditional sums"
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 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 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 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 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
2005 Jul 26
4
elegant solution to transform vector into percentages?
Hi,
I am looking for an elegant way to transform a vector into percentages of values
that meet certain criteria.
store<-c(1,1.4,3,1.1,0.3,0.6,4,5)
# now I want to get the precentages of values
# that fall into the categories <=M , >M & <=N , >N
# let
M <-.8
N <- 1.2
# In my real example I have many more of these cutoff-points
# What I did is:
out <- matrix(NA,1,3)
2005 Mar 15
3
Voice getting cutoff
Guys.. I just noticed that my grandstream handytone 286 ata are having
problems with voice cutoffs... We can listen to the person on the zap
channel (x100p cards) without problems but they sometimes listen to us with
cutoffs.. like "He ...lo..... ow...r.. you" and it comes and goes.. this
doesnt happen all the time but often enough.
Any ideas what might be happening or what do I need
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ó:
2002 Jun 21
2
special spots
can someone email me a list of special spots in quality
settings, or point me to a website that tells these
settings? i know i may be confusing, i'm talking about
like the jump between -q4.99 and -q5 because of the
whole lossy/lossless channel coupling, and filesize
jump...i also know somewhere above there there is
different high and low frequency cutoffs, and a point
where there IS NO
2006 Mar 31
3
ROC optimal threshold
hello,
I am using the ROC package to evaluate predictive models
I have successfully plot the ROC curve, however
?is there anyway to obtain the value of operating point=optimal threshold
value (i.e. the nearest point of the curve to the top-left corner of the
axes)?
thank you very much,
jose daniel anadon
area de ecologia
universidad miguel hernandez
espa?a
2012 Jan 17
2
net classification improvement?
Greetings,
I have generated several ROC curves and would like to compare the AUCs.
The data are cross sectional and the outcomes are binary. I am testing
which of several models provide the best discrimination. Would it be most
appropriate to report AUC with 95% CI's?
I have been looking in to the "net reclassification improvement" (see
below for reference) but thus far I can only
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
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
2004 Jun 11
1
ROC for threshold value, biometrics
Hello,
I am just a beginner of R 1.9.0.
I try to construct a predictive score for the development of liver
cancer in cirrhotic patients. So dependant variable is binanry (cancer
yes or no). Independant variables are biological data. The aim is to
find out a cut-off value which differentiate (theoratically) from
normal to pathological state for each biological data.
How can I step in procedue to
2009 Nov 19
1
problem post request with RCurl
Hi, I am trying to use a CGI service (Pubchem PUG) via RCurl and am
running into a problem where the data must be supplied via POST - but
I don't know the keyword for the argument.
The data to be sent is an XML fragment. I can do this via the command
line using curl: I save the XML string to a file called query.xml and
then do
curl -d @query.xml
2012 Mar 06
1
How to eliminate for next loops in this script
I needed to compute a complicated cross tabulation to show weighted means
and standard deviations and the only method I could get that worked uses a
series of nested for next loops. I know that there must be a better way to
do so, but could use some assistance pointing the way.
Here is my working, but inefficient script:
library(Hmisc)
rm(list=ls())
load('NHTS.Rdata')
day.wt <-
2012 Jan 06
1
Can levelplot colorkeys display a logarithmic scale evenly?
I'm using the {lattice} "levelplot" function to make a (more or less) 2-d
histogram, and for the most part it's working fine with my data. However, I
can't get the color key to do what I need. I can give it labels and custom
cutoffs, but my cutoff lines (and hence my labels) aren't evenly spaced, instead
they're more-or-less logarithmic, starting at
2018 Feb 12
2
What does pct mean?
Hi Carsten,
On 02/11/2018 at 07:46 PM Carsten Bock wrote:
> Hi,
>
> Lost percent (%)....
Are you sure? I'm seeing here:
...........Receive......... .........Transmit..........
Count Lost Pct Jitter Count Lost Pct Jitter RTT....
188K 0 0 0.000 188K 16641K 8809 0.000 0.026
=> This doesn't sound reliable to me: there are 188K packets and 16641K