Displaying 20 results from an estimated 40000 matches similar to: "difference of two rows"
2009 Feb 09
2
length of object in repeated measures
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
1 1 5.4
1 3 6.2
1 15 10.0
2 3 8.1
2 10 12.8
3 2 5.9
3 10 7.1
3 15 15.4
3 17
2009 Oct 21
1
re ferring to data of previous rows
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 female (Id) changes if she had
given birth to a pup in the previous year. So my dataframe consists of the
column Id, year (2003-2007 for each Id) and offspring (=of; 1-0):
Id year of
1 2003 1
1 2004 0
1
2009 Feb 20
3
mean over previous cells
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_date SST
2008-01-01 22.2
2008-01-02 21.8
2008-01-03 22.8
2008-01-04 22.9
2008-01-05 23.1
2008-01-06 23.2
...
2009 Jul 09
2
How to combine two rows (in a dataframe) into a third row?
Dear R-helpers,
I have two rows in my dataframe:
ID VALUE
1A 10
1B 15
and I would like to combine these two rows into a single (new) row in my
dataframe:
ID VALUE
1 25
...simply by specifying a new value for ID and summing the two VALUES.
I have been trying to do this with with rbind, but it's not working.
I'd appreciate any pointers.
Thanks, Mark Na
[[alternative
2010 Aug 24
2
How to remove rows based on frequency of factor and then difference date scores
Hello-
A basic question which has nonetheless floored me entirely. I have a
dataset which looks like this:
Type ID Date Value
A 1 16/09/2020 8
A 1 23/09/2010 9
B 3 18/8/2010 7
B 1 13/5/2010 6
There are two Types, which correspond to different individuals in
different conditions, and loads of ID labels (1:50)
2010 Jun 08
2
how to ignore rows missing arguments of a function when creating a function?
Hi,
I am relatively new to R; when creating functions, I run into problems with
missing values. I would like my functions to ignore rows with missing values
for arguments of my function) in the analysis (as for example is the case in
STATA). Note that I don't want my function to drop rows if there are missing
arguments elsewhere in a row, ie for variables that are not arguments of my
2004 Aug 03
2
attach data from tapply to dataframe
I am working with a longitudinal data set in the long format. This data
set has three observations per grade level per year. Here are the first
10 rows of the data frame:
>tenn.dat[1:10,]
year schid type grade gain se new cohort
6 2001 100005 5 4 33.1 3.5 4 3
7 2002 100005 5 4 33.9 3.9 4 2
8 2003 100005 5 4 32.3 4.2 4 1
10 2001 100005
2012 Aug 23
1
Extracting data from dataframe with tied rows
Hi R help,
I'm a fairly experienced R user but this manipulation has me stumped, please
help:
DATA
id<-rep(LETTERS[1:5],20)
distance<-rnorm(1:100, mean = 100)
bearing<-sample(1:360,100,replace=T)
month<-sample(1:12,100,replace=T)
I have a dataset with records of individuals (id) , each with a distance
(distance) & direction (bearing) recorded for each month (month).
I want
2007 Mar 20
6
Select the last two rows by id group
Hi R-users,
Following this post http://tolstoy.newcastle.edu.au/R/help/06/06/28965.html ,
how do I get last two rows (or six or ten) by id group out of the data
frame? Here the example gives just the last row.
Sincere thanks,
Lauri
[[alternative HTML version deleted]]
2006 Dec 07
2
Splitting a dataframe at the results of tapply
I have got a dataframe containing measurement of aircraft noise like
this:
> Id <- c(1,4,5,2,3,6,4,1,2,5,6,3)
> Noise <- c(88,94,97,98,92,56,103,102,87,95,92,97)
> Height <- c(190, 150, 120, 115, 188, 104, 101, 189, 146, 111, 124,
126)
>
> df <- data.frame(Id, Noise, Height)
Now I would like to split this in two new dataframes. The first one
containing the rows
2011 Jan 25
5
Counting number of rows with two criteria in dataframe
Hi R-users,
I'm trying to find an elegant way to count the number of rows in a dataframe
with a unique combination of 2 values in the dataframe. My data is
specifically one column with a year, one with a month, and one with a day.
I'm trying to count the number of days in each year/month combination. But
for simplicity's sake, the following dataset will do:
2009 Feb 23
1
"autonumber" for grouping variable
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 402 f 2003 29
4 402 f 2003 21
5 402 f 2003 64
6 150 m 2005 43
...
...(where Id is just the Identification number of Individual, sex (male or
female), byear (=birthyear))
now, I 'd like to add a column, where each Individual gets an automated
number starting
2006 Feb 24
3
Summarize by two-column factor, retaining original factors
I am having trouble doing the following. I have a data.frame like
this, where x and y are a variable that I want to do calculations on:
Name Year x y
ab 2001 15 3
ab 2001 10 2
ab 2002 12 8
ab 2003 7 10
dv 2002 10 15
dv 2002 3 2
dv 2003 1 15
Before I do all the other things I need to do with this data, I need
to summarize or collapse the data by name and year. I've
2009 Feb 27
3
Making tapply code more efficient
Previously, I posed the question pasted down below to the list and
received some very helpful responses. While the code suggestions
provided in response indeed work, they seem to only work with *very*
small data sets and so I wanted to follow up and see if anyone had ideas
for better efficiency. I was quite embarrased on this as our SAS
programmers cranked out programs that did this in the blink
2008 Nov 20
2
Calculating SD according to groups of rows
*Hi all,
I know this is probably basic, but I have proven to be a slow learner in any
programming language. Anyhow,
how can I calculate the SD for each person in my table? I have two patients
in this R data.frame, 7200 and 23955.
I extracted this from a relational database, but am I better off attempting
to compute SD in SQL, or is this easily accomplished in R?
* SUBJECT_ID HR
1
2010 Dec 24
4
Removing rows with earlier dates
Hi all,
I'm new to the list but have benfited from it quite extensively. Straight to
my rather strange question:
I have a data frame that contains mapping rules in this way:
ACCOUNT, RULE COLUMNS, Effective Date
The dataframe comes from a database that stores all dates. What I would like
to do is to create a data frame with only the most recent rule for each
account. In traditional
2011 Nov 06
1
Combining some duplicated rows & summing one of their column
Dear list,
I have this dataframe:
> names(events)
[1] "EID" "X" "Y" "trip" "tow" "catch" "effort" "depth"
[9] "season"
Where some of my unique ID "EID" appears more than once in 162 cases.
> length(events$EID)-length(unique(events$EID))
[1] 162
I would like to combined
2010 Jun 29
2
How to delete rows based on replicate values in one column with some extra calcuation
Hi, folks,
Please let me address the problem by the following codes:
first=c('u','b','e','k','j','c','u','f','c','e')
second=c('usa','Brazil','England','Korea','Japan','China','usa','France','China','England')
third=1:10
2006 May 30
2
average by group...
I have a dataframe with 700,000 rows and 2 vectors
(columns): ?group? and ?score?.
I wish to calculate a third vector of length 700000:
the average score by group. Even though the avarge
value will repeat, I wish to return the average for
that particular group for each row.
(I know I can do this by calculating each group?s
average and then using the merge command, but as my
calculations get
2001 Mar 22
2
Two-argument functions in tapply()
Hello to all.
My question is very simple...
Let's say we have a data frame with three variables (columns): X, W and F. X
is a numeric variable (e.g. like income) F is a factor (e.g. with 2 levels)
and W is a case weight (data are from household sample but an individual was
interviewed, weights are functions of number of persons in the house hold).
I wanted to compute a means of X weighted