[R] Help with rearranging data

2008-07-22 Thread William Pepe

In Excel, I have data that looks like this. 





Month
Seg
Prod
Biller
Cycle
Sales

1/1/2008
A
Table
Phyllis
1
500

1/1/2008
A
Table
Phyllis
2
600

1/1/2008
A
Table
Phyllis
3
650

1/1/2008
A
Table
Doreen
1
345

1/1/2008
A
Table
Doreen
2
451

1/1/2008
A
Table
Doreen
6
550

1/1/2008
A
Table
Doreen
9
590

1/1/2008
A
Table
Doreen
11
860

1/1/2008
A
Chair
Phyllis
1
300

1/1/2008
A
Chair
Phyllis
2
350

1/1/2008
B
Table
Phyllis
1
700

1/1/2008
B
Table
Phyllis
4
750

1/1/2008
B
Table
Phyllis
7
650

1/1/2008
B
Table
Doreen
1
800

1/1/2008
B
Table
Doreen
2
975

1/1/2008
B
Chair
Phyllis
1
400

1/1/2008
B
Chair
Phyllis
2
450

1/1/2008
B
Chair
Doreen
3
560

1/1/2008
B
Chair
Doreen
5
550

2/1/2008
A
Table
Phyllis
2
900

2/1/2008
A
Table
Phyllis
3
950

2/1/2008
A
Table
Doreen
1
780

2/1/2008
A
Table
Doreen
2
800

2/1/2008
A
Chair
Phyllis
1
450

2/1/2008
A
Chair
Phyllis
2
440

2/1/2008
A
Chair
Doreen
2
425

2/1/2008
A
Chair
Doreen
3
390

2/1/2008
B
Table
Phyllis
1
875

2/1/2008
B
Table
Phyllis
2
800

2/1/2008
B
Table
Doreen
2
675

2/1/2008
B
Table
Doreen
3
885

2/1/2008
B
Chair
Phyllis
1
450

2/1/2008
B
Chair
Doreen
2

435

2/1/2008
B
Chair
Doreen
3
400
 I want to rearrange the data so that I have columns such as SegProd
Biller   CycleJan Sales   Feb Sales  A  Table   Phyllis   1 500 
  0 A  Table   Phyllis   2 600 900 A  
Table   Phyllis   3 650 950 A  Table   Doreen  1
 345 780 A  Table   Doreen  2 451 800 A 
 Table   Doreen  6 5500 A  Table   Doreen  9
 5900 A  Table   Doreen 11860 0and 
so on. Any ideas on how this can be done, I would be greatly appreciative. 
Thanks, Sonic
_


_WL_Refresh_messenger_video_072008
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help with rearranging data

2008-07-22 Thread William Pepe

Yes, my apologies, I want to do this in R.
 
> Date: Tue, 22 Jul 2008 11:33:01 -0700> From: [EMAIL PROTECTED]> To: [EMAIL 
> PROTECTED]> CC: r-help@r-project.org> Subject: Re: [R] Help with rearranging 
> data> > Hi,> > is your question how you do this in R? Note that this is a 
> mailing> list for R. There are probably other lists/groups better suited for> 
> Excel-specific problems.> > Cheers> > Henrik> > On Tue, Jul 22, 2008 at 10:59 
> AM, William Pepe <[EMAIL PROTECTED]> wrote:> >> > In Excel, I have data that 
> looks like this.> >> >> >> >> >> > Month> > Seg> > Prod> > Biller> > Cycle> > 
> Sales> >> > 1/1/2008> > A> > Table> > Phyllis> > 1> > 500> >> > 1/1/2008> > 
> A> > Table> > Phyllis> > 2> > 600> >> > 1/1/2008> > A> > Table> > Phyllis> > 
> 3> > 650> >> > 1/1/2008> > A> > Table> > Doreen> > 1> > 345> >> > 1/1/2008> > 
> A> > Table> > Doreen> > 2> > 451> >> > 1/1/2008> > A> > Table> > Doreen> > 6> 
> > 550> >> > 1/1/2008> > A> > Table> > Doreen> > 9> > 590> >> > 1/1/2008> > A> 
> > Table> > Doreen> > 11> > 860> >> > 1/1/2008>!
  > A> > Chair> > Phyllis> > 1> > 300> >> > 1/1/2008> > A> > Chair> > Phyllis> 
> 2> > 350> >> > 1/1/2008> > B> > Table> > Phyllis> > 1> > 700> >> > 1/1/2008> 
> B> > Table> > Phyllis> > 4> > 750> >> > 1/1/2008> > B> > Table> > Phyllis> > 
7> > 650> >> > 1/1/2008> > B> > Table> > Doreen> > 1> > 800> >> > 1/1/2008> > 
B> > Table> > Doreen> > 2> > 975> >> > 1/1/2008> > B> > Chair> > Phyllis> > 1> 
> 400> >> > 1/1/2008> > B> > Chair> > Phyllis> > 2> > 450> >> > 1/1/2008> > B> 
> Chair> > Doreen> > 3> > 560> >> > 1/1/2008> > B> > Chair> > Doreen> > 5> > 
550> >> > 2/1/2008> > A> > Table> > Phyllis> > 2> > 900> >> > 2/1/2008> > A> > 
Table> > Phyllis> > 3> > 950> >> > 2/1/2008> > A> > Table> > Doreen> > 1> > 
780> >> > 2/1/2008> > A> > Table> > Doreen> > 2> > 800> >> > 2/1/2008> > A> > 
Chair> > Phyllis> > 1> > 450> >> > 2/1/2008> > A> > Chair> > Phyllis> > 2> > 
440> >> > 2/1/2008> > A> > Chair> > Doreen> > 2> > 425> >> > 2/1/2008> > A> > 
Chair> > Doreen> > 3> > 390> >> > 2/1/2008> > B> > !
 Table> > Phyllis> > 1> > 875> >> > 2/1/2008> > B> > Table> > Phyllis> 
> 2> > 800> >> > 2/1/2008> > B> > Table> > Doreen> > 2> > 675> >> > 2/1/2008> > 
> B> > Table> > Doreen> > 3> > 885> >> > 2/1/2008> > B> > Chair> > Phyllis> > 
> 1> > 450> >> > 2/1/2008> > B> > Chair> > Doreen> > 2> >> > 435> >> > 
> 2/1/2008> > B> > Chair> > Doreen> > 3> > 400> > I want to rearrange the data 
> so that I have columns such as Seg Prod Biller Cycle Jan Sales Feb Sales A 
> Table Phyllis 1 500 0 A Table Phyllis 2 600 900 A Table Phyllis 3 650 950 A 
> Table Doreen 1 345 780 A Table Doreen 2 451 800 A Table Doreen 6 550 0 A 
> Table Doreen 9 590 0 A Table Doreen 11 860 0and so on. Any ideas on how this 
> can be done, I would be greatly appreciative. Thanks, Sonic> > 
> _> >> >> > 
> _WL_Refresh_messenger_video_072008> > [[alternative HTML version deleted]]> 
> >> > __> > R-help@r-project.org 
> mailing list> > https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do 
> read the posting guide!
  http://www.R-project.org/posting-guide.html> > and provide commented, 
minimal, self-contained, reproducible code.> >> > 
__> R-help@r-project.org mailing 
list> https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting 
guide http://www.R-project.org/posting-guide.html> and provide commented, 
minimal, self-contained, reproducible code.
_
[[elided Hotmail spam]]

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Moving Average Question

2008-08-14 Thread William Pepe

Dear all. I have data that looks like this:
 
Biller Cycle Jan Feb  Mar Apr May JuneAB   1   100 150 150 200 300 450JL
2   650 600 750 700 850 800JL3   700 740 680 690 700 580IR1 
  455 400 405 410 505 550IR4   600 650 700 750 650 680IR5   100 
150 120 130 140 190IR9   600 640 630 625 680 690
 
For each biller and cycle, I want to determine the six months average for 
Jan-Jun and also a 3-month moving average for Jan-Jun.
 
If a cycle number is skipped such as cycle 1 for biller JL, that just means 
there is no cycle 1 for biller JL. It's not missing data.
 
Any help would be greatly appreciated. Thanks.
_


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Question about subsetting data

2008-06-03 Thread William Pepe

I have a data set(Bill) of with 1 variable (var1), with 100 obs that are in 
ascending order. I want to sample every 10 observations and save them in 10 
different groups such as
 
  Group1 is obs 1-10
  Group 2 is obs-11-20
 
and so on.
 
First step is to subset them into the 10 groups, then calculate the mean of 
var1 for each of the 10 groups. Any help would be appreciated. Thanks.
 
_


sh_skydrive_062008
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Similar question about subsetting data

2008-06-03 Thread William Pepe

This is just a slight modification of a question I asked earlier. Thanks to all 
the responders.
 
I have a data set(Bill) of with 1 variable (var1), with 100 obs that are in 
ascending order. I want to sample every 10 observations and save them in 10 
different groups such as   Group1 is obs 1-10  Group 2 is obs-11-20  Subset 
data into the 10 groups, then calculate the mean/0.8 of var1 for each of the 10 
groups. 
The mean/0.8 is the modification. Thanks.
_
It’s easy to add contacts from Facebook and other social sites through Wi
https://www.invite2messenger.net/im/?source=TXT_EML_WLH_LearnHow
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] merging 3 data sets at once

2008-06-04 Thread William Pepe

I could suggest merge(merge(data1,data2), data3). 
 
However, one problem I notice is that is assigns age=12 and gender=M to 
everyone with id=1, and so on.
 
How are we to know that person with id=1 in data1 is the same person with id=1 
in data2 and data3? 
Bill> Date: Wed, 4 Jun 2008 16:24:04 -0700> From: [EMAIL PROTECTED]> To: 
r-help@r-project.org> Subject: [R] merging 3 data sets at once> > > Hi All,> > 
I am looking into merging 3 data sets I know how to do that by merging data1> 
with data2 and then merging the result with data 3. I was wondering if it> can 
be done all at once so I tried,> > M<-merge(data1,data2,data3, by=”ID”)> > It 
does not work!> Any ideas?> > > > -- > View this message in context: 
http://www.nabble.com/merging-3-data-sets-at-once-tp17658873p17658873.html> 
Sent from the R help mailing list archive at Nabble.com.> > 
__> R-help@r-project.org mailing 
list> https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting 
guide http://www.R-project.org/posting-guide.html> and provide commented, 
minimal, self-contained, reproducible code.
_
Instantly invite friends from Facebook and other social networks to join yo
https://www.invite2messenger.net/im/?source=TXT_EML_WLH_InviteFriends
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] merging 3 data sets at once

2008-06-04 Thread William Pepe

By the way, I used age and gender as examples. Plus, I've seen something very 
similar posted a while ago. If the problem I listed isn't an issue, then that 
code will work.
 
Best,
 
Bill


From: [EMAIL PROTECTED]: [EMAIL PROTECTED]; [EMAIL PROTECTED]: RE: [R] merging 
3 data sets at onceDate: Wed, 4 Jun 2008 20:50:34 -0400


I could suggest merge(merge(data1,data2), data3).  However, one problem I 
notice is that is assigns age=12 and gender=M to everyone with id=1, and so on. 
How are we to know that person with id=1 in data1 is the same person with id=1 
in data2 and data3? Bill> Date: Wed, 4 Jun 2008 16:24:04 -0700> From: [EMAIL 
PROTECTED]> To: r-help@r-project.org> Subject: [R] merging 3 data sets at once> 
> > Hi All,> > I am looking into merging 3 data sets I know how to do that by 
merging data1> with data2 and then merging the result with data 3. I was 
wondering if it> can be done all at once so I tried,> > 
M<-merge(data1,data2,data3, by=”ID”)> > It does not work!> Any ideas?> > > > -- 
> View this message in context: 
http://www.nabble.com/merging-3-data-sets-at-once-tp17658873p17658873.html> 
Sent from the R help mailing list archive at Nabble.com.> > 
__> R-help@r-project.org mailing 
list> https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting 
guide http://www.R-project.org/posting-guide.html> and provide commented, 
minimal, self-contained, reproducible code.

Instantly invite friends from Facebook and other social networks to join you on 
Windows Live™ Messenger. Invite friends now! 
_
Now you can invite friends from Facebook and other groups to join you on Wi
https://www.invite2messenger.net/im/?source=TXT_EML_WLH_AddNow_Now
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Graphing help

2008-06-05 Thread William Pepe

Hoping someone can help me with some graphics. Here is my data set. 
 





   
A B

 1
5

1
5

1
6

2
7

3
7

4
7

5
8

6
9

6
10
   7  11
Using this code, I split the data into two groups, each of size 5, and made a 
scatterplot.
 
Bill<-read.table('something here') 
attach(Bill)Bill.s<-split(Bill, rep(1:2, each=5))
plot(A,B,col='black')
$`1`  A B1 1 52 1 53 1 64 2 75 3 7
$`2`  A  B 6 4  7 7 5  8 8 6  9 9 6 1010 7 11 
For each group, I calculate the mean of BFor group 1, mean of B is 6. For 
group 2, mean of B is 9.
 
On the scatterplot of A vs. B, for group 1, I want a horizontal line at the 
mean of 6. It should only cover group 1.
For group 2, a horizontal line at the mean of 9. Again, should only cover the 
points in group 2.
 
The endpoints of the different horizontal lines must connect.
 
Can anybody give me any help? Thanks in advance.
 
Bill
_


sh_skydrive_062008
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Graphing help revisited

2008-06-05 Thread William Pepe

Sorry, my last post came out unreadable. I'll try again. Here is the data. 
Think of them as transposed columns. A: 1,1,1,2,3,4,5,6,6, 7B: 
5,5,6,7,7,7,8,9,10,11   Split the data into two groups, each of size 5, and 
make a scatterplot. Bill<-read.table('something here') 
attach(Bill)Bill.s<-split(Bill, rep(1:2, each=5))plot(A,B,col='black')  Group 
1:A:1,1,1,2,3B:5,5,6,7,7Group 2:A:4,5,6,6,7B:7,8,9,10,11 For each group, find 
the mean of B Group 1:mean=6. Group 2: mean=9. On the scatterplot of A vs. 
B: For group 1, need horizontal line at the mean of 6. It should only cover the 
points in group 1.For group 2, need horizontal line at the mean of 9. Again, 
should only cover the points in group 2. The endpoints of the different 
horizontal lines must connect. 
 
I rather do this where I can change the size of the group as well. Any help is 
greatly appreciated. Bill
_
Search that pays you back! Introducing Live Search cashback.

rchpaysyouback
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] col.names ?

2008-06-06 Thread William Pepe

As a very simple example: 
TolgaData<-data.frame(A=c(1,2),B=c(3,4))names(TolgaData )<- c( "newA", "newB" 
)> TolgaData Column names should now be newA and newB Best,  Bill> To: 
r-help@r-project.org> From: [EMAIL PROTECTED]> Date: Fri, 6 Jun 2008 20:06:41 
+0100> Subject: [R] col.names ?> > Dear R Users,> > A bit of an elementary 
question, but somehow, I haven't been able to > figure it out. I'd like to 
changes the column names of a data frame, so I > am looking for something like 
col.names (as in row.names). Could someone > please show me how to change the 
column names of a data frame ?> > Thanks,> Tolga> > Generally, this 
communication is for informational purposes only> and it is not intended as an 
offer or solicitation for the purchase> or sale of any financial instrument or 
as an official confirmation> of any transaction. In the event you are receiving 
the offering> materials attached below related to your interest in hedge funds 
or> private equity, this communica!
 tion may be intended as an offer or> solicitation for the purchase or sale of 
such fund(s). All market> prices, data and other information are not warranted 
as to> completeness or accuracy and are subject to change without notice.> Any 
comments or statements made herein do not necessarily reflect> those of 
JPMorgan Chase & Co., its subsidiaries and affiliates.> > This transmission may 
contain information that is privileged,> confidential, legally privileged, 
and/or exempt from disclosure> under applicable law. If you are not the 
intended recipient, you> are hereby notified that any disclosure, copying, 
distribution, or> use of the information contained herein (including any 
reliance> thereon) is STRICTLY PROHIBITED. Although this transmission and any> 
attachments are believed to be free of any virus or other defect> that might 
affect any computer system into which it is received and> opened, it is the 
responsibility of the recipient to ensure that it> is virus free and no r!
 esponsibility is accepted by JPMorgan Chase &> Co., its subsidiaries a
nd affiliates, as applicable, for any loss> or damage arising in any way from 
its use. If you received this> transmission in error, please immediately 
contact the sender and> destroy the material in its entirety, whether in 
electronic or hard> copy format. Thank you.> Please refer to 
http://www.jpmorgan.com/pages/disclosures for> disclosures relating to UK legal 
entities.> [[alternative HTML version deleted]]> > 
__> R-help@r-project.org mailing 
list> https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting 
guide http://www.R-project.org/posting-guide.html> and provide commented, 
minimal, self-contained, reproducible code.
_


sh_skydrive_062008
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] overall title

2008-06-12 Thread William Pepe

Check out this previous post from years ago.
 
http://tolstoy.newcastle.edu.au/R/help/00a/2237.html
 
Bill> Date: Thu, 12 Jun 2008 10:38:03 -0500> From: [EMAIL PROTECTED]> To: 
r-help@r-project.org> Subject: [R] overall title> > I have a 2x2 plot set up 
using: par(mfrow=c(2,2))> I'd like to put an overall title on the page, but I 
cannot figure out how. Any ideas?> > > [[alternative HTML version deleted]]> > 
__> R-help@r-project.org mailing 
list> https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting 
guide http://www.R-project.org/posting-guide.html> and provide commented, 
minimal, self-contained, reproducible code.
_
Instantly invite friends from Facebook and other social networks to join yo
https://www.invite2messenger.net/im/?source=TXT_EML_WLH_InviteFriends
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.