On Wednesday, September 19, 2012, Jul_biologyGrad wrote:
> Thanks everyone for the help! I pulled together a bunch of your suggestions
> to get the result that I needed. I'm posting my final code below. Probably
> not the most efficient way of doing things but gets the job done in a way
> that a n
Thanks everyone for the help! I pulled together a bunch of your suggestions
to get the result that I needed. I'm posting my final code below. Probably
not the most efficient way of doing things but gets the job done in a way
that a newbie can understand!
##Here again is the example dataset
Sample
A.K.
>
>
>
> - Original Message -
> From: Julie Lee-Yaw
> To: "r-help@r-project.org"
> Cc:
> Sent: Monday, September 17, 2012 7:15 PM
> Subject: [R] help with calculation from dataframe with multiple entries per
> sample
>
> Hi
>
=length(unique(mydata$Sample)))
Error in `$<-.data.frame`(`*tmp*`, "Gain", value = c(0.3, 0.3, 0.3,
0.101, :
replacement has 9 rows, data has 10
>
>
>
>
> - Original Message -
> From: Julie Lee-Yaw
> To: "r-help@r-project.org&qu
17, 2012 7:15 PM
Subject: [R] help with calculation from dataframe with multiple entries per
sample
Hi
I have a dataframe similar to:
>Sample<-c(1,1,1,2,2,2,3,3,3)
>Time<-c(1,2,3,1,2,3,1,2,3)
>Mass<-c(3,3.1,3.4,4,4.3,4.4,3,3.2,3.5)
>mydata<-as.data.frame(cbind(Sample,T
2 3 4.4 0.1
#7 3 1 3.0 0.3
#8 3 2 3.2 0.3
#9 3 3 3.5 0.3
A.K.
- Original Message -
From: Julie Lee-Yaw
To: "r-help@r-project.org"
Cc:
Sent: Monday, September 17, 2012 7:15 PM
Subject: [R] help with calculation from dataframe with multipl
Or diff(x[2:3])
Rui Barradas
Em 18-09-2012 01:05, David Winsemius escreveu:
On Sep 17, 2012, at 5:00 PM, David Winsemius wrote:
On Sep 17, 2012, at 4:15 PM, Julie Lee-Yaw wrote:
Hi
I have a dataframe similar to:
Sample<-c(1,1,1,2,2,2,3,3,3)
Time<-c(1,2,3,1,2,3,1,2,3)
Mass<-c(3,3.1,3.4,4,4
On Sep 17, 2012, at 5:00 PM, David Winsemius wrote:
>
> On Sep 17, 2012, at 4:15 PM, Julie Lee-Yaw wrote:
>
>> Hi
>>
>> I have a dataframe similar to:
>>
>>> Sample<-c(1,1,1,2,2,2,3,3,3)
>>
>>> Time<-c(1,2,3,1,2,3,1,2,3)
>>
>>> Mass<-c(3,3.1,3.4,4,4.3,4.4,3,3.2,3.5)
>>
>>> mydata<-as.data
On Sep 17, 2012, at 4:15 PM, Julie Lee-Yaw wrote:
> Hi
>
> I have a dataframe similar to:
>
>> Sample<-c(1,1,1,2,2,2,3,3,3)
>
>> Time<-c(1,2,3,1,2,3,1,2,3)
>
>> Mass<-c(3,3.1,3.4,4,4.3,4.4,3,3.2,3.5)
>
>> mydata<-as.data.frame(cbind(Sample,Time,Mass))
>
Please tell me where you learned tha
Hello,
Try the following.
sp <- split(mydata, mydata$Sample)
do.call(rbind, lapply(sp, function(x){x$Gain <- x$Mass[3] - x$Mass[2]; x}))
Hope this helps,
Rui Barradas
Em 18-09-2012 00:15, Julie Lee-Yaw escreveu:
> Hi
>
> I have a dataframe similar to:
>
>> Sample<-c(1,1,1,2,2,2,3,3,3)
>> Time<-
Julie -
Since the apply functions operate on one row at a time, they
can't do what you want. I think the easiest way to solve your
problem is to reshape the data set, and merge it back with the
original:
dd = data.frame(Sample=c(1,1,1,2,2,2,3,3,3),
+ Time=c(1,2,3,1,2,3,1,
Hi
I have a dataframe similar to:
>Sample<-c(1,1,1,2,2,2,3,3,3)
>Time<-c(1,2,3,1,2,3,1,2,3)
>Mass<-c(3,3.1,3.4,4,4.3,4.4,3,3.2,3.5)
>mydata<-as.data.frame(cbind(Sample,Time,Mass))
Sample Time Mass
1 1 1 3.0
2 1 2 3.1
3 1 3 3.4
4 2 1 4.0
5 2 2 4
12 matches
Mail list logo