e(x$YEAR, x$ID, FUN=function(a) c(diff(a), NA))
>>
>> x
> ID YEAR diff
> 1 13 2007 NA
> 2 15 20033
> 3 15 20062
> 4 15 2008 NA
> 5 21 20061
> 6 21 2007 NA
>
>
> On Wed, Nov 25, 2009 at 10:55 AM, clion wrote:
>>
>> Dear R user
Dear R user,
I'd like to calculate the difference of two rows, where "ID" is the same.
eg.: I've got the following dataframe:
ID YEAR
13 2007
15 2003
15 2006
15 2008
21 2006
21 2007
and I'd like to get the difference, like this:
ID YEAR diff
13 2007 NA
15 2003 3
15 2006 2
15
(NA, head(x, -1)))
>
>
> On Wed, Oct 21, 2009 at 2:55 AM, clion wrote:
>>
>> Dear Rlers,
>> in the following dataset I would like to insert a new column that refers
>> to
>> the data of the previous row.
>> My question is whether the probability of a fema
1 NA
1 2004 0 1
1 2005 1 0
1 2006 1 1
1 2007 0 1
2 2003 0 NA
2 2004 1 0
2 2005 1 1
2 2006 0 1
2 2007 1 0
3 2003 1 NA
3 2004 1 1
3 2005 1 1
3 2006 0 1
3 2007 0 0
any idea how I could program that?
thanks a lot,
Dear R users,
my dataframe looks like this
head(dat)
Id sex byear age
1 300 m 2003 50
2 300 m 2003 36
3 402f 2003 29
4 402f 2003 21
5 402f 2003 64
6 150 m 2005 43
...
...(where Id is just the Identification number of Individual, sex (male or
female), byear (=birth
well, it "kind of works"
now, I get means from the 61st SST-value on (which is reasonable, so no
"carful discarding" of the first 60 values) but aswell I only get means
until the 186st SST-value (although I 've got about 4900 in total). Allt
the rest is "NA" - besides the 60th value is "NaN"
Any
Dear RUsers,
I guess this is an easy question for someone a little familiar with
programming...(which I am not)...
I've got 2 colummns, one shows just dates(SST_date, Class 'Date' num), the
other one shows the SeaSurfaceTemperature (SST, num) at that certain date.
SST_dateSST
2008-01-01 22.
gt; dat
>
>
> I hope it helps.
>
> Best,
> Dimitris
>
>
> clion wrote:
>> Hi there.
>> I collectad data of several animals (Id) that were caught and measured at
>> several occasions.
>> The dataframe looks like this:
>> Grouped Data: mass ~ age |
Hi there.
I collectad data of several animals (Id) that were caught and measured at
several occasions.
The dataframe looks like this:
Grouped Data: mass ~ age | Id
Id age mass
11 5.4
13 6.2
1 15 10.0
23 8.1
2 10
9 matches
Mail list logo