similar to: how to select the first observation only?

Displaying 20 results from an estimated 20000 matches similar to: "how to select the first observation only?"

2009 Jan 02
7
the first and last observation for each subject
I have the following data ID x y time 1 10 20 0 1 10 30 1 1 10 40 2 2 12 23 0 2 12 25 1 2 12 28 2 2 12 38 3 3 5 10 0 3 5 15 2 ..... x is time invariant, ID is the subject id number, y is changing over time. I want to find out the difference between the first and last observed y value for each subject and get a table like ID x y 1 10 20 2 12 15 3 5 5 ...... Is there any easy way to generate
2010 Apr 20
1
how to select the last non-'NA' observation in a row
I have a matrix of the following form: time id 0 2 4 6 9 12 14 3 9 8 NA NA NA NA NA 7 3 NA 3 NA 3 NA 4 13 11 6 7 NA 5 NA 6 ..... I hope for each row to select the last observation which is not 'NA'. For example, for the first row, id=3, the value I want to select is 8 for the second row, id=7, the value I want to select is 4 for the third row, id=13, the
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
2009 Mar 29
2
select observations from longitudinal data
Suppose I have a long format for a longitudinal data id time x 1 1 10 1 2 11 1 3 23 1 4 23 2 2 12 2 3 13 2 4 14 3 1 11 3 3 15 3 4 18 3 5 21 4 2 22 4 3 27 4 6 29 I want to select the x values for each ID when time is equal to 3. When that observation is not observed, then I want to replace it with the obervation at time equal to 4. otherwise just use NA. How can I implement this with a quick
2009 Mar 12
4
who can give me some hint?
Hi All, > act_2 Date Dtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 55 2006-02-22 14:52:49 14 52 49 4 57 2006-02-22 14:52:51 14 52 51 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54
2008 Nov 24
3
select a subset
I have the complete data like id time censor 1 10 0 1 20 0 1 30 0 2 10 0 2 20 1 2 30 0 2 40 0 3 10 0 3 20 0 3 30 1 .... for id 1, i want to select the last row since all censor indicator is 0; for id 2, i want to select the row where censor ==1; for id 3, i also want to select the row where censor==1. So if there is a 1 for censor, then I want to select such a row, otherwise I want to select the
2012 Oct 16
5
uniq -c
I need an analogue of "uniq -c" for a data frame. xtabs(), although dog slow, would have footed the bill nicely: --8<---------------cut here---------------start------------->8--- > x <- data.frame(a=1:32,b=1:32,c=1:32,d=1:32,e=1:32) > system.time(subset(as.data.frame(xtabs( ~. , x )), Freq != 0 )) user system elapsed 12.788 4.288 17.224 --8<---------------cut
2011 Jul 20
3
select element from each row of the matrix
I have a 5 column matrix like 12 10 8 6 3 10 9 8 7 5 14 NA 4 NA NA NA 15 NA 10 NA 5 ... I want to select the position of the first entry for each row <=5 for example, for the first row, I want to select the last element and return its position as 5; for th e third row, I want to select the third element and return its position as 3; similarly for the 4th row, I want to select the fifth
2011 Aug 08
1
select from matrix
Suppose I have a matrix like A=matrix(0,4,6) A[1,]=c(16,10,2,4,8,7) A[2,]=c(16,10,12,14,8,7) A[3,]=c(16,10,13,15,19,17) A[4,]=c(16,9,13,15,9,7) > A [,1] [,2] [,3] [,4] [,5] [,6] [1,] 16 10 2 4 8 7 [2,] 16 10 12 14 8 7 [3,] 16 10 13 15 19 17 [4,] 16 9 13 15 9 7 I want to creat an indicator variable X which takes three values: X=1
2016 May 09
3
Switching between Music on Hold streams. [13.8.2]
Hi there; I didn't see any "G" option in the example above, and the usage for the option parameters is entirely undocumented at https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Application_Dial The G options are as below G - If the call is answered, transfer the calling party to the specified priority and the called party to the specified priority plus one. context exten
2012 Oct 24
1
randomly select another observation with same grouping factor and year value, do for every record in dataframe
Hello, I am trying to create a function that will move through each record of a data frame, find the value in the "HUC" column, then randomly select another observation from the dataframe with the same value in "HUC" column, as well as the same value in "Yr" column as the first observation. I want the function to produce a list of the RchID of the first observation,
2007 Jan 27
2
unequal number of observations for longitudinal data
i have a large longitudinal data set. The number of observations for each subject is not the same across the sample. The largest number of a subject is 5 and the smallest number is 1. now i want to make each subject to have the same number of observations by filling zero, e.g., my original sample is id x 001 10 001 30 001 20 002 10 002 20 002 40 002 80 002 70 003 20 003 40 004 ...... now i wish
2009 Sep 05
1
how do I draw this surface -- hand drawn in the attachemtn
Basially I have the observation for x, y, and z for each fixed z, the value of y moves from 0 to y0 as x moves from 0 to x0. I then move the curve for z from 0 to z0 and form a continuous surface. want to know if there is a way that R can replace my handdrawing. -------------- next part -------------- A non-text attachment was scrubbed... Name: draw0001.pdf Type: application/pdf Size: 292083
2007 May 27
2
Looking for the first observation within the month
Hi all, I have a simple data frame, first list is a list of dates (in "%Y-%m-%d" format) and second list an observation on that particular date. There might not be observations everyday. Let's just say there are no observations on saturdays and sundays. Now I want to select the first observation of every month into a list. Is there an easy way to do that? Date
2008 May 26
1
To draw observation [m, n] from 20 data frames named frame1, ... , frame20
Hi all, I have 20 data frames, named frame1, ... , frame20. Each data frame has the dimension 20x5. I need to build a function that calls out the observation in Row 1, Col 2 from all 20 data frames and places it in a vector of length 20. I have tried the following code: vect <- rep(0,20) for(i in 1:20){ vect[i] <- paste("frame",i,"[1,2]",sep="") } The
2006 Sep 06
3
plot axises on both sides of a graph
Usually the y-axis is shown on the left-hand-side of a graph, is it possible to artifically creat one more y-axis on the right-hand-side in R? What is the main reference? Thank you in advance. [[alternative HTML version deleted]]
2007 May 05
3
Tell me why my Shoutcase handler sucks!
So, I want to build the greatest online radio ever! (for my, currently crappy, faderwave.net radio station. Right now, I''m running Icecast straight up. The only problem is that managing different DJs and keeping them off the air when they aren''t supposed to be there is a pain. There also is not one single management package that does everything. My current system is a hacked
2007 Jun 10
3
find position
find the position of the first value who equals certain number in a vector: Say a=c(0,0,0,0,0.2, 0.2, 0.4,0.4,0.5) i wish to return the index value in a for which the value in the vector is equal to 0.4 for the first time. in this case, it is 7. [[alternative HTML version deleted]]
2010 Jan 27
3
Function for describing segements in sequential data
Dear R-users, Say that I have a sequence of zeroes and ones: x <- c(1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0) The sequences of ones represent segments and I want to report the starting and endpoints of these segments. For example, in 'x', the first segment starts at location 1 and ends at 3, and the second segment starts at location 8 and ends at location 10. Is there an efficient
2008 Nov 24
3
count the cumulative for each subject
I have a data set like the following: subject visit x1 1 1 0.5 1 2 1.2 1 3 0.7 2 1 0.4 2 2 0.6 2 3 1.0 ..... where x1 is the interval between the two visits. Now I want to calculate the cumulative intervals since the beinging, for example subject visit x1 cum 1 1 0.5 0.5 1 2 1.2 0.5+1.2 1 3 0.7 0.5+1.2+0.7 2 1 0.4 0.4 2 2 0.6 0.4+0.6 2 3 1.0 0.4+0.6+1.0 ..... is there an easy to generate the