similar to: obtaining first and last record for rows with same identifier

Displaying 20 results from an estimated 2000 matches similar to: "obtaining first and last record for rows with same identifier"

2005 May 18
1
from list to dataframe
I was wondering if someone can help me figure out the following: I have two patient datasets, ds1 and ds2. ds1 has fields "patid", "date", and "lab1". ds2 has "patid", "date", and "lab2". I want to find all the patids that have at least 2 dated records for each lab. I started by splitting each dataset by patid, to create ds1.list
2006 Mar 25
7
Regexp subexpression
I can't get the PERL subexpression translated to R. Following, for example, B. Ripley's http://finzi.psych.upenn.edu/R/Rhelp02a/archive/58984.html I am using sub, but it looks like an ugly substitute. Assume I want to extract the first alpha part and the first numeric part, but only if they are in sequence. Do I really have to use the sub twice, first extracting the first variable, then
2004 Sep 22
1
impenetrable warning
Dear R-help, Can anyone explain the meaning of the warning, Singular precision matrix in level -1, block 1 ? Or how to track down where it comes from? More precisely, using the nlme package, I'm issued with the warning itt2 <- lme(lrna~rx.nrti+lbrna, random=~1|patid, cor=corExp(form=~days|patid,nugget=T), weights=varPower( form=~lbrna),data=rna3) Warning messages: 1: Singular
2012 Nov 17
3
manipulating longitudinal data in r
Dear list member, I have the following data example ke <- data.frame(patid=c(1,1,1,2,3,3),a=c(1,2,2,1,1,2)) I want to add another variable b, such that the max of 'a' by id is returned i.e data ke becomes ke <- data.frame(patid=c(1,1,1,2,3,3),a=c(1,2,2,1,1,2),b=c(2,2,2,1,2,2)) Any help will be appreciated. Oluwakemi [[alternative HTML version deleted]]
2003 May 14
2
number of patients in a hospital on a given date
Dear R-users! I am using R 1.7.0, under Windows XP. Having some hospital discharge data (admission date and discharge date for each patient), I want to get the number of patients in the hospital on a given date. My data look like (simple example): > x <- data.frame(patid=c("pat1", "pat2"), adm.date = c("15.03.2002", "16.03.2002"),
2005 May 31
2
simple predict question
Excuse the simple question... I'm not sure what I'm doing wrong with predict, but let me use this example: Suppose I do: dat<-matrix(c(0,0,10,20),2,byrow=T) lm1<-lm(dat[,2]~dat[,1]) Suppose I want to generate the linearly-interpolated y-values between the point (0,0) and (0,20) at every unit interval. I thought I just do: predict(lm1, data.frame(seq(0,10,1))) to get
2005 May 06
2
2 simple questions
Please excuse what I'm sure are very easy questions but I'm relatively new to the R environment. How can I view a range of list elements, but not all. e.g., I had a matrix of patients and then split them out by patient id. I know I can do patlist[[1]] to see the first one, but how can I view, say, the first ten patients? My other question is how to count how many patients have a
2007 Mar 27
1
basic handling of data.frame
Hello, I'm new to R but wan't to use it to compute the statistics of my medical study. The study includes several parameters for a number of patients. Each parameter was assessed by a number of readers, once with a special condition, once without. Now I have a data.frame with colums like: PatientID, ReaderID, SpecialCond(yes/no), Parameter1, Parameter2..... the rows are not sorted, and
2008 Oct 31
1
subset with variable number of subset arguments
I've got a big data.frame from which I need to extract data based on a variable number of Id's (InfCode). Until now I've been using the following dull solution as I never needed to search for more than 5 codes. Now my needs have increased faster than my R skills did and I need to call my function with about 25 values for x. There has to be a *apply or even simpler solution which
2011 Aug 01
1
Inserting column in between -- "better" way?
Folks: I consider my reply below rather clumsy: One has to keep track of index numbers other than that which is inserted and must separately change column names. Is there as "essentially better" way to do this, either via base R or via an R package. I leave it to you to define "essentially better." Thanks. Cheers, Bert On Mon, Aug 1, 2011 at 10:17 AM, Bert Gunter
2005 Jun 09
2
Weibull survival modeling with covariate
I was wondering if someone familiar with survival analysis can help me with the following. I would like to fit a Weibull curve, that may be dependent on a covariate, my dataframe "labdata" that has the fields "cov", "time", and "censor". Do I do the following? wieb<-survreg(Surv(labdata$time, labadata$censor)~labdata$cov,
2008 May 10
3
Compact Indicator Matrices
An indicator matrix is a binary matrix with orthogonal columns whose rows sum to 1. A row of this matrix could be [0 1 0 0]. My problem is to group the similar rows (profiles) so that to create a compact form of the matrix. Is there an R function that deals with this problem or do I have to write it from scratch? Thanks, Angelos Markos Dr. Applied Informatics, University of Macedonia, Greece
2012 Oct 11
1
replacing ugly for loops
I have a couple of hundred American Community Survey Summary Files files containing rectangular arrays of data, mainly though not exclusively numeric. Each file is referred to as a sequence (henceforth "seq"). From these files I am trying to extract particular subsets (tables) consisting of a sets of columns. These tables are defined by three numbers (now in columns in a data frame):
2005 Aug 22
1
plotting with same axes
I have used the 'par' command to overlay one plot on another. But how do I overlay it with the x-values plotted at the same points on the x-axis? Thank you, Steven
2005 May 05
2
efficient filtering of matrices
I was wondering if someone can tell me the best way to search through a matrix and choose certain rows (based on certain conditions) to put into a separate matrix. What I have tried so far is very slow for a large dataset I'm working with. e.g., I have this piece of code to create a new matrix (newmat) based on my filtering conditions. Do I need to do this kind of thing where I keep
2009 Feb 08
5
glmmBUGS: logistic regression on proportional data
Hello, I am trying to run a logistic regression with random effects on proportional data in glmmBUGS. I am a newcomer to this package, and wondered if anyone could help me specify the model correctly. I am trying to specify the response variable, /yseed/, as # of successes out of total observations... but I suspect that given the error below, that is not correct. Also, Newsect should be a
2010 Sep 11
3
confidence bands for a quasipoisson glm
Dear all, I have a quasipoisson glm for which I need confidence bands in a graphic: gm6 <- glm(num_leaves ~ b_dist_min_new, family = quasipoisson, data = beva) summary(gm6) library('VIM') b_dist_min_new <- as.numeric(prepare(beva$dist_min, scaling="classical", transformation="logarithm")). My first steps for the solution are following: range(b_dist_min_new)
2012 Jun 06
3
Sobel's test for mediation and lme4/nlme
Hello, Any advice or pointers for implementing Sobel's test for mediation in 2-level model setting? For fitting the hierarchical models, I am using "lme4" but could also revert to "nlme" since it is a relatively simple varying intercept model and they yield identical estimates. I apologize for this is an R question with an embedded statistical question. I noticed that a
2017 Aug 09
3
Plotting log transformed predicted values from lme
Hi, I am performing meta-regression using linear mixed-effect model with the lme() function that has two fixed effect variables;one as a log transformed variable (x) and one as factor (y) variable, and two nested random intercept terms. I want to save the predicted values from that model and show the log curve in a plot ; predicted~log(x) mod<-lme(B~log(x)+as.factor(y),
2004 Jan 08
3
Strange parametrization in polr
In Venables \& Ripley 3rd edition (p. 231) the proportional odds model is described as: logit(p<=k) = zeta_k + eta but polr apparently thinks there is a minus in front of eta, as is apprent below. Is this a bug og a feature I have overlooked? Here is the naked code for reproduction, below the results. ------------------------------------------------------------------------ --- version