similar to: how to select the last non-'NA' observation in a row

Displaying 20 results from an estimated 20000 matches similar to: "how to select the last non-'NA' observation in a row"

2009 Apr 26
2
Help to select the raw in a data.frame with the max value
Dear User, thank for the attention. I have a data.frame with 5 columns (ex:ID, a1,a2,a3,a4) and 1000 rows. I wish to find the absolute max value for all data.frame and save a new data.frame with the row where is that value. Ex: ID: 1,2,3,4,5,6,7,8,9,10 a1:1,2,3,4,5,6,7,8,9,10 a2:11,12,13,14,15,16,17,18,19,20 a3:21,22,23,24,25,26,27,28,29,30 a4:31,32,33,34,35,36,37,38,39,40 The
2009 Jul 15
4
Extract pairs (rowname, columname) from a matrix where value is 0
Dear sir, I have a matrix like a<-matrix(c(0,2,0,4,0,6,5,8,0),nrow=3) colnames(a)<-c("F1","F2","F3") rownames(a)<-c("A1","A2","A3") a F1 F2 F3 A1 0 4 5 A2 2 0 8 A3 0 6 0 I want to extract all pairs (rownames, columnames) from which the value in the matrix is 0 The result should be something like this A1, F1 A2,
2009 Mar 20
4
how to make aggregation in R ?
Hi, I am trying to aggregate the sum of my test data.frame as follow: testDF <- data.frame(v1 = c("a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "c", "c", "c", "c", "c", "d", "d", "d", "d",
2011 Jul 04
1
placing multiple rows in a single row
Dear people from the R help list, I have a question that I can't get my head around to start answering, that is why I am writing to the list. I have data in a format like this (tabs might look weird): John A1 1 0 1 John A2 1 1 1 John A3 1 0 0 Mary A1 1 0 1 Mary A2 0 0 1 Mary A3 1 1 0 Peter A1 1
2006 Oct 22
1
disaggregating table
Hi all, This should be easy, but I can't seem to figure it out. I have a table like this named newtable a1 a2 a3 a4 Cnts Score 1 1 0 0 4 3.28 1 0 1 1 2 2.63 I want the following: a1 a2 a3 a4 Cnts Score 1 1 0 0 4 3.28 1 1 0 0 4 3.28 1 1 0 0 4 3.28 1 1 0 0
2010 Jun 17
3
ask a question about data sets element
for example, I have a1=c(1,3,5) a2=c(2,4,6) a3=c(7,8) a4=c(9,10) now if I have i=5, so i in a1, then I get a feedback tag[5]=1 i=8, so i in a3, then can get tag[8]=3 in there any function to do this to check the element belongs to which group? thank you!!! [[alternative HTML version deleted]]
2009 Jan 18
2
select observations from longitudinal data set
I have the following longitudinal data: id time y 1 1 10 1 2 12 1 3 15 1 6 18 2 1 8 2 3 9 2 4 11 2 5 12 3 1 8 3 4 16 4 1 9 4 5 13 5 1 7 5 2 9 5 6 11 .... I want to select the observations at time 4. if the observation at time 4 is missing, then i want to slect the observation at time 3. if the observation at time 3 is also missing, then i want to select observation at time 5. otherwise i will
2008 Sep 23
1
Summing up columns with NA elements in a data frame
Hi all, When I try to sum a few columns in a data frame (which has NA?s randomly distributed as elements), I am not able to get the summing operation to ignore the NA?s. Let me explain with the following code : ################################? a<-structure(list(a1 = c(NA, 2, 3, NA, 5, 6, NA, 8, 9, NA), a2 = c(NA, + 4, 5, 5, NA, 7, 8, 8, NA, 10), a3 = c(2, NA, 6, 8, NA, 12, 14, + NA, 18, 20)),
2008 Oct 24
1
Request: Most repeated sequence considering combinations at each row
Dear friends Hope you all are fine. Suppose we have a list of arrays. a1=c(4,4,4,4,0,4,4,4,0,3,3,0,0,0,0,0); a1=array(a1,dim=c(4,4)); a2=c(4,4,4,4,0,4,4,4,0,3,3,0,0,0,0,0); a2=array(a2,dim=c(4,4)); a3=c(4,4,4,4,0,3,3,4,0,4,4,0,0,0,0,0); a3=array(a3,dim=c(4,4)); a4=c(4,4,4,4,4,0,3,3,3,3,0,4,4,4,0,0,0,0,0,0); a4=array(a4,dim=c(5,4)); a5=c(4,4,4,4,4,0,4,4,4,4,0,3,3,3,0,0,1,1,0,0);
2004 Dec 06
3
removing NA as a level
Dear R-helpers, I have a problem which I suppose is trivila, but... I have included NA values as factors ( (to be able to make nice printed summaries with NAs % ba category ) with the following code dat$x.f<-factor(dat$x, exclude=NULL); levels(dat$x.f)<-c("A1","A2","A3","A4","NA"); length(dat$x.f) Now, I want to impute the missing values.
2011 Apr 12
2
Testing equality of coefficients in coxph model
Dear all, I'm running a coxph model of the form: coxph(Surv(Start, End, Death.ID) ~ x1 + x2 + a1 + a2 + a3) Within this model, I would like to compare the influence of x1 and x2 on the hazard rate. Specifically I am interested in testing whether the estimated coefficient for x1 is equal (or not) to the estimated coefficient for x2. I was thinking of using a Chow-test for this but the Chow
2009 Apr 22
1
Gee with nested desgin
Dear all, Is it possible to incorporate a nested design in GEE? I have measurements on trees that where measured in two years. The trees are nested in plots. Each plot contains 24 trees. The number of plots is 72. Hence we would expect 2 * 24 * 72 = 3456 data points. A few are missing, so we end up wih 3431 data points. This is what I have tried until now. #assuming independence between trees
2008 Jul 31
2
sort rows of matrix by rows of another matrix
Hello all, I am trying to sort rows of one matrix by rows of another. Given a1 and a2: ------ > a1 [,1] [,2] [,3] [1,] 7 6 8 [2,] 4 2 4 [3,] 4 7 2 [4,] 0 3 8 a1 <- structure(c(7, 4, 4, 0, 6, 2, 7, 3, 8, 4, 2, 8), .Dim = c(4L, 3L)) > a2 [,1] [,2] [,3] [1,] 101 102 103 [2,] 101 102 103 [3,] 101 102 103 [4,] 101 102 103 a2 <-
2003 Nov 18
1
aov with Error and lme
Hi I searched in the list and only found questions without answers e.g. http://finzi.psych.upenn.edu/R/Rhelp02a/archive/19955.html : Is there a way to get the same results with lme as with aov with Error()? Can anybody reproduce the following results with lme: id<-c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5)
2011 Jul 05
3
plotting survival curves (multiple curves on single graph)
Hello. This is a follow-up to a question I posted last week. With some previous suggestions from the R-help community, I have been able to plot survival (, hazard, and density) curves using published data for Siler hazard parameters from a number of ethnographic populations. Can the function below be modified, perhaps with a "for" statement, so that multiple curves (different line
2008 Sep 10
6
request: most repeated component of a list
Dear R community I have stored the results of arrays in a list consist of J-components (say 200 components). Each component containing same no of columns but may be different no of rows. e.g [[1]] [,1] [,2] [,3] [,4] [,5] [1,] 4 0 0 0 0 [2,] 4 3 4 0 0 [3,] 4 3 4 0 0 [4,] 4 3 0 0 0 [[2]] [,1] [,2] [,3] [,4] [,5]
2010 Jul 20
2
Means from selected columns in a data frame
Hi all, I have a dataframe with survey data. Now I want to calculate means from several but not all columns (e.g. a1, a2, a3) and save them in a new separate column (e.g. a). Like: a = mean(a1, a2, a3) Can someone help me or give me the right key word to look for? Thanks [[alternative HTML version deleted]]
2009 Oct 29
3
Removing & generating data by category
Dear R users, Basically, from the following arbitrary data set: a <- data.frame(id=c(c("A1","A2","A3","A4","A5"),c("A3","A2","A3","A4","A5")),loc=c("B1","B2","B3","B4","B5"),clm=c(rep(("General"),6),rep("Life",4))) > a
2003 Sep 26
3
An interesting call path observation..
This is not really a problem just something I noticed in my testing.. When two or more Asterisk servers are connected by IAX2 trunks it does not make use of any "shortest path" type system.. (maybe this is still planned somwhere down the line, but may come in handy to those who have multi asterisk installations) Here is the setup.. UA1--- Asterisk1----[IAX2 Trunk]---Asterisk2---UA2
2009 Sep 04
1
User defined function's argument as Subset function's input
Dear R users, I have a data where I desire to subset according to certain conditions. However, the script is very messy as there are about 30 distinct conditions. (i.e. same script but with different conditions) I would like to make a user defined function so that I can input the desired conditions and just get the results accordingly. Below is an arbitrary data set & sample statements