Hi,
Please use ?dput() to show the datasets as one of the rows (Id "four") in first
dataset didn't show 11 elements.
df1 <- structure(list(Id = c("one", "one", "two", "two", "three", "three",
"three", "four", "five", "five"), col1 = c("a1", NA, "b1", "b1",
NA, NA, "c1", "d1", "e1", NA), col2
Thanks.
Why does
> aggregate(z, list(id=z$id),FUN=list)
id id a1 a2
1 10 10, 10, 10 a, a, b x, x, z
2 20 20, 20b, by, y
3 30 30 c z
work, but
aggregate(z, list(id=z$id),FUN=function(l) {
t <- sort(table(l),decreasing=TRUE)
list(length(t),t[
Hi,
Try this:
z1<-aggregate(z,list(id=z$id),FUN=paste,sep=",")
dat1<-data.frame(id=z1[,1],a1.total=unlist(lapply(z1[,3],length)),a1.val1=unique(z$a1),a1.num=unlist(lapply(lapply(z1[,3],table),`[`,1)),a1.val2=unlist(lapply(z1[,3],`[`,3)),a1.num2=unlist(lapply(lapply(z1[,3],table),`[`,2)),a2.total=u
was another problem.
Now, all suggestions by all three posts to solve this aggregation work
perfectly.
Thanks to all.
Ken
-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Friday, August 20, 2010 11:12 AM
To: Hall, Ken (CDC/OSELS/NCPHI)
Subject: Re: [R] Aggreg
, Ken
> (CDC/OSELS/NCPHI)
> Sent: Friday, August 20, 2010 7:40 AM
> To: Phil Spector
> Cc: r-help@r-project.org
> Subject: Re: [R] Aggregate Help
>
> The first one worked great. Thanks for the quick response.
>
> The second one, with the "with" statement,
di...@gmail.com]
Sent: Thursday, August 19, 2010 5:13 PM
To: Hall, Ken (CDC/OSELS/NCPHI)
Cc: r-help@r-project.org
Subject: Re: [R] Aggregate Help
On Thu, Aug 19, 2010 at 4:45 PM, Hall, Ken (CDC/OSELS/NCPHI)
wrote:
> Please let me know if this is or is not the right place to ask these
&g
dually
and the group, just the group or just individually? Or does it depend on
the context of my response?
-Original Message-
From: Phil Spector [mailto:spec...@stat.berkeley.edu]
Sent: Thursday, August 19, 2010 5:00 PM
To: Hall, Ken (CDC/OSELS/NCPHI)
Cc: r-help@r-project.org
Subje
On Thu, Aug 19, 2010 at 4:45 PM, Hall, Ken (CDC/OSELS/NCPHI)
wrote:
> Please let me know if this is or is not the right place to ask these
> types of questions.
>
> Warning: I am new to R by two days.
>
> I have a simple dataset.
> I have loaded the dataset successfully using the following code:
>
On Aug 19, 2010, at 4:45 PM, Hall, Ken (CDC/OSELS/NCPHI) wrote:
Please let me know if this is or is not the right place to ask these
types of questions.
Warning: I am new to R by two days.
I have a simple dataset.
I have loaded the dataset successfully using the following code:
Filepath=(C:\
Ken -
Try
aggregate(Pilot$Count,list(Date=Pilot$Date,illness=Pilot$illness),sum)
If you don't want to keep typing "Pilot", use
with(Pilot,aggregate(Count,list(Date=Date,illness=illness),sum))
Notice that the aggregated variable will be called "x" in the output
data frame from aggregate.
10 matches
Mail list logo