similar to: Subsetting for the ten highest values by group in a dataframe

Displaying 20 results from an estimated 5000 matches similar to: "Subsetting for the ten highest values by group in a dataframe"

2010 Mar 12
5
Vertical subtraction in dataframes
Hello all, I have not been able to find an answer to this problem. I feel like it might be so simple though that it might not get a response. Suppose I have a dataframe like the one I have copied below (minus the 'calib' column). I wish to create a column like calib where I am subtracting the 'Count' when 'stain' is 'none' from all other 'Count' data for
2009 Dec 28
2
Modified R Code
Dear R helpers,   I have following input files. (Actually they are more than 10 rates but here i am considering only 2 rates to write my problem)   rate1.csv min1        max1            min2          max2          min3           max3 1.05        1.30               1.30          1.65             1.65          1.99   rate2.csv min1        max1            min2          max2          min3          
2008 Apr 15
1
disturbing seed dependence in optim L-BFGS-B method
The the use of optim with the L-BFGS-B method for the following simple function gives erroneous results. Any help appreciated! Best, Bob Reilly # Code: V=function(p){ p1=p[1];p2=p[2] y=p1*p2-.4*(p1+p2) return(-y)} p=c(.2,.2) # p=c(.8,.8) max=optim(p,V,method = "L-BFGS-B",lower=c(0,0),upper=c(1,1)) max1=optim(max$par,V,method = "L-BFGS-B",lower=c(0,0),upper=c(1,1))
2017 Jan 23
1
[PATCH] virtio_net: fix PAGE_SIZE > 64k
I don't have any guests with PAGE_SIZE > 64k but the code seems to be clearly broken in that case as PAGE_SIZE / MERGEABLE_BUFFER_ALIGN will need more than 8 bit and so the code in mergeable_ctx_to_buf_address does not give us the actual true size. Cc: John Fastabend <john.fastabend at gmail.com> Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- Lightly tested on x86
2017 Jan 23
1
[PATCH] virtio_net: fix PAGE_SIZE > 64k
I don't have any guests with PAGE_SIZE > 64k but the code seems to be clearly broken in that case as PAGE_SIZE / MERGEABLE_BUFFER_ALIGN will need more than 8 bit and so the code in mergeable_ctx_to_buf_address does not give us the actual true size. Cc: John Fastabend <john.fastabend at gmail.com> Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- Lightly tested on x86
2016 Nov 08
2
should we have IR intrinsics for integer min/max?
Thanks, Hal and Matt for the feedback. As usual, my instincts about canonicalization were probably wrong. :) I thought that @max1 vs. @max3 would be viewed as an unknowable trade-off between reducing the dependency chain and the pseudo-canonical min/max form, so we'd add intrinsics, and defer that decision to the backend. I'll wait to see if there are any other arguments presented.
2013 Sep 17
1
ayuda con aggregate
Hola, ¿qué tal? Creo que la forma más limpia es usar la función ddply de plyr aproximadamente así: ddply(mis.datos, .(B, C), summarise, mean.X2 = mean(X2), medianX4 = median(X4), etc. ) La sección "Using ddply" de http://www.cookbook-r.com/Manipulating_data/Summarizing_data/ lo expica bastante bien. Un saludo, Carlos J. Gil Bellosta
2009 Jun 04
3
Fast way of finding top-n values of a long vector
If x is a (long) vector and n << length(x), what is a fast way of finding the top-n values of x? Some suggestions (calculating the ratio of the two top values): library("rbenchmark") set.seed(1); x <- runif(1e6, max=1e7); x[1] <- NA; benchmark( replications=20, columns=c("test","elapsed"), order="elapsed" , sort = {a<-sort(x,
2012 Jun 01
1
Drop values of one dataframe based on the value of another
Hello all, Let me first say that this isn't a question about outliers. I am using the outlier function from the outliers package but I am using it only because it is a convenient wrapper to determine values that have the largest difference between itself and the sample mean. Where I am running into problems is that I am several groups where I want to calculate the "outlier" within
2009 May 25
3
long format - find age when another variable is first 'high'
Dear R, I've got a data frame with children examined multiple times and at various ages. I'm trying to find the first age at which another variable (LDL-Cholesterol) is >= 130 mg/dL; for some children, this may never happen. I can do this with transformBy and ddply, but with 10,000 different children, these functions take some time on my PCs - is there a faster way to do this in R?
2016 Nov 07
5
should we have IR intrinsics for integer min/max?
Hi - The answer to this question may help to resolve larger questions about intrinsics and vectorization that were discussed at the dev mtg last week, but let's start with the basics: Which, if any, of these is the canonical IR? ; ret = x < y ? 0 : x-y define i32 @max1(i32 %x, i32 %y) { %sub = sub nsw i32 %x, %y %cmp = icmp slt i32 %x, %y ; cmp is independent of sub %sel = select
2010 Apr 29
1
Using plyr::dply more (memory) efficiently?
Hi all, In short: I'm running ddply on an admittedly (somehow) large data.frame (not that large). It runs fine until it finishes and gets to the "collating" part where all subsets of my data.frame have been summarized and they are being reassembled into the final summary data.frame (sorry, don't know the correct plyr terminology). During collation, my R workspace RAM usage goes
2013 Jan 31
3
Locate Patients who have multiple high blood pressure readings
On Thu, Jan 31, 2013 at 10:29 AM, Weijia Wang <wwang.nyu@gmail.com> wrote: > Hi, > > > > I have a new question about subsetting in R. > > > > Say we have this data frame: > > > > PT_ID Blood_Pressure OBS_TYPE > > 92 1900 90.0 DBP > > 94 1900 90.0 DBP > > 174 2900 140.0 SBP > > 176 2900
2011 May 17
1
Subsetting depth profiles based on maximum depth by group with plyr
Hello, Apologies for a similar earlier post. I didn't include enough details in that one. I am having a little trouble subsetting some data based on a grouping variable. I am using an instrument that does depth profiles of a water column. The instrument records on the way down as well as the way up. So thanks to an off-list reply I can subset the data so that all data collected at the
2013 Apr 26
1
Stratified Random Sampling Proportional to Size
Hello R Experts, I kindly request your assistance on figuring out how to get a stratified random sampling proportional to 100. Below is my r code showing what I did and the error I'm getting with sampling::strata # FIRST I summarized count of records by the two variables I want to use as strata Library(RODBC) library(sqldf) library(sampling) #After establishing connection I query the data
2007 Nov 08
3
skip non-sequential lines using scan?
Hi all, Is there a way to skip non-sequential lines using the "skip" argument in the scan function? E.g., I have a matrix with 100 rows and 1e7 columns. I open a connection and want to read only lines 5, 7, 9, etc [i.e., seq(5,99,2)] It might seem that the syntax to do this would be something like this (if only the "skip" allowed vectors in the same way colClasses does in
2011 Jun 09
2
Calculating a mean based on a factor range
Hello all, I have been using an instrument that collects a temperature profile of a water column. The instrument records the temperature and depth any time it takes a reading. I was sampling many times at discrete depth rather than a complete profile of the water column (e.g. interested in 5m, 10m and 20m depth position only). The issue was that these measurement were taken with the instrument
2009 Apr 28
3
truehist and density plots
Hi, I wanted to plot the histogram of a vector and then, plot the density function of subsets of the vector on the histogram. So I use truehist in MASS package and lines(density) as follows: length(b) = 1000 truehist(b) lines(density(b[1:100])) however the density plot of the first 100 points exceeds the max of y axis (see attached). how is it possible to make a graphics so that the density plot
2010 Feb 17
3
Extending data frame with longer columns
Hi, I am a beginner in R and have only read a few chapters in the R book, I was not able to find a solution for this simple problem. I have an empty data frame: a=data.frame(name="test") which I would like to extend in a for-loop (with data extracted from a database). Ideally I would like to extend the data frame like this: a["new_1"] = 1:10 a["new_1"] = 1:12
2010 Dec 07
4
Creating binary variable depending on strings of two dataframes
Hi, consider the following two dataframes: x1=c("232","3454","3455","342","13") x2=c("1","1","1","0","0") data1=data.frame(x1,x2) y1=c("232","232","3454","3454","3455","342","13","13","13","13")