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
NA 2 y 2
> #2 30 1 c 1 NA 1 z 1
> # a2.num2
> #0 1
> #1 NA
> #2 NA
> #It is not an elegant way!
>
>
> A.K.
>
>
>
> - Original Message -
> From: Sam Steingold
>
Original Message -
From: Sam Steingold
To: r-help@r-project.org
Cc:
Sent: Thursday, September 20, 2012 2:06 PM
Subject: [R] aggregate help
I want to count attributes of IDs:
--8<---cut here---start->8---
z <- data.frame(id=c(10,20,10,30,10,20),
I want to count attributes of IDs:
--8<---cut here---start->8---
z <- data.frame(id=c(10,20,10,30,10,20),
a1=c("a","b","a","c","b","b"),
a2=c("x","y","x","z","z","y"),
stringsAsFactors=FALSE)
> z
id a1 a2
1 10 a
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
ct: Re: [R] Aggregate Help
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&
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.
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:\temp\\pilot\dataset1.txt")
Pilot=read.table(filepath, header=TRUE)
12 matches
Mail list logo