[R] Help on write.xlsx library(xlsx)

2010-09-06 Thread Ravi S. Shankar
Hi Adrian,

 

dat=data.frame(matrix(0,3,3))

 

write.xlsx(dat,z:/dat.xlsx,sheetName=sheet1,append=F)

write.xlsx(dat,z:/dat.xlsx,sheetName=sheet2,append=F)

 

The above code works and creates new worksheets. But if I want to append
to an existing worksheet I seem to get an error.

 

write.xlsx(dat,z:/dat.xlsx,sheetName=sheet2,append=T) - This gives
an error saying The workbook already contains a sheet of this name

 

Could you please let me know how to append data to  an existing sheet
and not create a new sheet each time?

 

Thank you

Ravi

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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 on Select.list

2010-09-03 Thread Ravi S. Shankar
Hi R,

 

I am using select.list 

names=c(Ravi, Raj,Shubha,Nivriti)

select.list(names)  provides a drop down to choose one of the 4 names.

 

However I would like to know if it is possible to create a
classification  something like this

 

select.list(names) should give 

 

Boys

Ravi 

Raj

Girls

Shubha

Nivriti

I should be able to choose only one of the names. 

Any help would be appreciated.

 

R version 2.10.1 (2009-12-14) 

i386-pc-mingw32 

 

locale:

[1] LC_COLLATE=English_United States.1252 

[2] LC_CTYPE=English_United States.1252   

[3] LC_MONETARY=English_United States.1252

[4] LC_NUMERIC=C  

[5] LC_TIME=English_United States.1252

 

attached base packages:

[1] stats graphics  grDevices datasets  utils methods   base


 

other attached packages:

[1] clim.pact_2.2-41 akima_0.5-4  ncdf_1.6.1   rcom_2.2-3  

[5] rscproxy_1.3-1  

 

loaded via a namespace (and not attached):

[1] tools_2.10.1

 

Thank you

Regards

Ravi

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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 on Select.list

2010-09-03 Thread Ravi S. Shankar
Hi David,
Thank you for your response. But that wasn't what I was looking for.
names=c(Ravi, Raj,Shubha,Nivriti)
select.list(names)  gives a pop up with the 4 names. I just wanted in
the pop up a heading (say BOYS) followed by two names and another
heading (say GIRLS) and the remaining two names.

Is there a way I can include headings in the select.list()


Thank you once again for the help.
Regards
Ravi

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Friday, September 03, 2010 6:14 PM
To: Ravi S. Shankar
Cc: r-h...@stat.math.ethz.ch
Subject: Re: [R] Help on Select.list


On Sep 3, 2010, at 3:55 AM, Ravi S. Shankar wrote:

 Hi R,



 I am using select.list

 names=c(Ravi, Raj,Shubha,Nivriti)

 select.list(names)  provides a drop down to choose one of the 4 names.



 However I would like to know if it is possible to create a
 classification  something like this



 select.list(names) should give


See if these beginnings get you any further:

  ifelse( names %in% c(Ravi, Raj) ,Boys, Girls)
[1] Boys  Boys  Girls Girls


  names[names %in% c(Ravi, Raj)]
[1] Ravi Raj
  names[!(names %in% c(Ravi, Raj))]
[1] Shubha  Nivriti

In any case you will need to provided a master list of either (or  
both) boy names and girl names.



 Boys

 Ravi

 Raj

 Girls

 Shubha

 Nivriti

 I should be able to choose only one of the names.

I'm afraid that did not make much sense to me.

-- 
David.

 Any help would be appreciated.



 R version 2.10.1 (2009-12-14)

 i386-pc-mingw32



 locale:

 [1] LC_COLLATE=English_United States.1252

 [2] LC_CTYPE=English_United States.1252

 [3] LC_MONETARY=English_United States.1252

 [4] LC_NUMERIC=C

 [5] LC_TIME=English_United States.1252



 attached base packages:

 [1] stats graphics  grDevices datasets  utils methods   base




 other attached packages:

 [1] clim.pact_2.2-41 akima_0.5-4  ncdf_1.6.1   rcom_2.2-3

 [5] rscproxy_1.3-1



 loaded via a namespace (and not attached):

 [1] tools_2.10.1



 Thank you

 Regards

 Ravi



 This e-mail may contain confidential and/or privileged i...{{dropped: 
 13}}

 __
 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.

David Winsemius, MD
West Hartford, CT

This e-mail may contain confidential and/or privileged i...{{dropped:10}}

__
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] Barplots

2010-07-13 Thread Ravi S. Shankar
Hi R,

 

I am examining the mean returns 10 days before and 10 days after a
event. Now I have several events the corresponding pre and post event 10
day mean returns... something like this

 

Pre_Start  Pre_End  Pre_MeanPre_SD
Post_StartPost_EndPost_Mean
Post_SD

1  2002-02-22  2002-03-08  0.004968027
0.017443954   2002-03-12  2002-03-25  0.0004099697
0.012529438

2  2002-04-25  2002-05-08  -0.006371706
0.011008257  2002-05-10  2002-05-23  -0.0022429404
0.007736497

3  2002-07-24  2002-08-06  0.005083225
0.015508255   2002-08-08  2002-08-21  0.0048237816
0.008116529

4  2002-07-24  2002-08-06  0.005083225
0.015508255   2002-08-08  2002-08-21 0.0048237816
0.008116529

5  2003-01-08  2003-01-21 0.004439480
0.012310963   2003-01-23  2003-02-05 -0.0064620002
0.012731789

 

I obtained a barplot using the below

layout(matrix(c(1,1,2,2),ncol=2,byrow=T))

barplot(rnorm(10),main=Pre_Event_Returns,col=red)

barplot(rnorm(10),main=Post_Event_Returns,col=blue)

 

However I would like to know if it is possible to do the following-
merge the two barplots i.e. a single barplot which will include both the
pre and post event returns 

Any suggestions would be appreciated

Ravi

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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] skip for loop

2010-04-05 Thread Ravi S. Shankar
Hi R,

 

I am running a for loop in which I am doing a certain calculation. As an
outcome of calculation I get an out put say a. Now in my for loop I
needs to be initiated to a. 

 

Based the below example if the output a=3 then the second iteration
needs to be skipped. Is there a way to do this? 

for(i in 1:5)

{

##Calculation##

a=3 ## outcome of calculation

}

 

Any help appreciated. Thanks in advance for the time!

 

Regards

Ravi

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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] subtract a specified number of days from current date

2010-04-05 Thread Ravi S. Shankar
Hi R,

 

I have a column with dates. I need to create a vector say from (current
date-90 days: current date) 

 

For example I need to subtract 90 days from say Sys.Date()-92

 

If Sys.Date()-92 ==  Sunday, Sys.Date()-92+1

if Sys.Date()-92 ==  Saturday, Sys.Date()-92+2

 

i.e if subtracting gives me a weekend I  need the next work day.

 

I used the below. 

ifelse(weekdays(seq(seq(tf[[i]][j,1],by=-1
day,length.out=90)[90])==Saturday,match(seq(tf[[i]][j,1],by=-1
day,length.out=90)[90]+2,tf[[i]][,1]),ifelse(weekdays(seq(tf[[i]][j,1],
by=-1 day,length.out=90)[90])==Sunday,match(seq(tf[[i]][j,1],by=-1
day,length.out=90)[90]+1,tf[[i]][,1]),match(seq(tf[[i]][j, 1],by=-1
day,length.out=90)[90],tf[[i]][,1])))

I would be grateful If anybody can help me with a more elegant/efficient
approach.

Thank you in advance for your time!

Ravi 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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] Calculating the trading days

2009-07-16 Thread Ravi S. Shankar
Hi R,

I have two columns of date in a CSV file in the below format
29-Dec-06   25-Jan-07
29-Dec-06   25-Jan-07
29-Dec-06   25-Jan-07
2-Jan-0725-Jan-07
2-Jan-0725-Jan-07
2-Jan-0725-Jan-07

I read in R using   dat-read.csv(Z:\\data.csv). 
 class(dat[,1])
[1] factor

So I use
dat[,1]=as.Date(as.character(dat[,1]),%d-%b-%YY)
 class(dat[,1])
[1] Date
 But when I do 
 fix(dat)
Warning: class discarded from column 'Date'
Also 
 dat[1,1]
[1] NA

My task is to compute the number of trading days between the two dates
in col A and Col B. Any help would be appreciated!

Thank you,
Ravi Shankar S 
This e-mail may contain confidential and/or privileged i...{{dropped:10}}

__
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] combine words and dataframe

2009-04-09 Thread Ravi S. Shankar
Hi R,

 

I am trying to get an output like this

 

Hi

Hello

1   a   b

2   a   b

3   a   b

4   a   b

5   a   b

 

And write it as a text file

 

cat(paste(Hi,sep='\n',Hello)) gives me

Hi

Hello

 

And when I try
cat(paste(Hi,sep='\n',Hello),sep='\n',data.frame(rep(a,3),rep(b,
3))) I get an error!

 

Thanks in advance for your help!

 

Regards

Ravi

 

 

 

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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] write text file as output without quotes

2009-04-07 Thread Ravi S. Shankar
Hi R,

 

When I use the below to write the text file

try=data.frame(rep(a,5), rep(b,5))

write.table(try,z:\\try.txt,row.names=F,col.names=F,sep=\t)

 

the output contains two columns with quotes! Is there a way to write
without quotes?

I tried 

try[,1]=noquote(try[,1])

try[,2]=noquote(try[,2]) 

 

Thank you,

Regards,

Ravi Shankar

 

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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] convert matrix to dataframe with repeating row names

2008-10-20 Thread Ravi S. Shankar
Hi R,

 

I have a matrix x with repeating row names. 

 dim(x)

[1] 862  19

 

zz-matrix(0,4,4)

rownames(zz)=c(a,a,b,b)

data.frame(zz) (?)

 

 

I need to use x in a linear regression

lm(as.formula(paste(final_dat[,5]~,paste(colnames(x),collapse=+))),x
)

this gives me a error

 

Error in model.frame.default(formula =
as.formula(paste(final_dat[,5]~,  : 

  'data' must be a data.frame, not a matrix or an array

 

 

 sessionInfo()

R version 2.7.1 (2008-06-23) 

i386-pc-mingw32 

 

locale:

LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

 

attached base packages:

[1] stats graphics  grDevices utils datasets  methods   base


 

other attached packages:

[1] xlsReadWrite_1.3.2

 

Thanks in advance

Ravi

 

 

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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 with CrossTable

2008-09-30 Thread Ravi S. Shankar
Hi,

 

I am using the CrossTable function from library(gmodels).

 

x=unique(data[,c(L1,L1_Revenues,RIC)])

L1_Classification=CrossTable(x$L1,x$L1_Revenues,exclude =
c(NA,,0%,0),prop.r=FALSE,prop.c=FALSE,prop.t=FALSE,prop.chisq=FA
LSE,dnn=c(L1_Classification,Revenue))

 

What I would like to do is to get the out put in excel. Also I do not
want the output displayed on the console. Is there some way of doing
this?

 

sessionInfo()

R version 2.7.1 (2008-06-23) 

i386-pc-mingw32 

 

locale:

LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

 

attached base packages:

[1] stats graphics  grDevices utils datasets  methods   base


 

other attached packages:

[1] gmodels_2.14.1 xlsReadWrite_1.3.2

 

loaded via a namespace (and not attached):

[1] gdata_2.4.2  gtools_2.5.0 MASS_7.2-42

 

Thank you,

Ravi

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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] Replace with previous value

2008-03-26 Thread Ravi S. Shankar
Hi R,

I have a dataframe with
dim(test)
[1] 435150  4
class(test)
[1] data.frame
In the third column every time a number with - appears I need to
replace with previous value
I am using the following code
s=which(substr(as.character(test[,3]),1,1)==-)
 for(i in 1:length(s)) test[s[i],3] = test[s[i]-1,3]

Is there a faster way of doing this?

sessionInfo()
R version 2.5.1 (2007-06-27) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics  grDevices utils datasets
methods  
[7] base 
Thanks in advance


Ravi Shankar S 
 

This e-mail may contain confidential and/or privileged i...{{dropped:10}}

__
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] Range across a List

2008-03-26 Thread Ravi S. Shankar
Hi R,
I have a list
 class(pp2)
[1] list
 
 length(pp2)
[1] 1244

It is in the below format
  RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price
ABCD.SZ   2008/02/29   15.30CNY  0.1408  2.154240
ABCD.SZ   2008/01/31   15.27CNY  0.1392  2.125584
ABCD.SZ   2007/12/31   14.88CNY  0.1371  2.040048
ABCD.SZ   2007/11/30   11.07CNY  0.1357  1.502199
ABCD.SZ   2007/10/31   10.89CNY  0.1340  1.459260
ABCD.SZ   2007/09/28   12.77CNY  0.1334  1.703518

I want to find the range of pp2$New.Price for length(pp2) for each date
Any help would be appreciated

Thanks in advance
Ravi


This e-mail may contain confidential and/or privileged i...{{dropped:10}}

__
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] Range across a List

2008-03-26 Thread Ravi S. Shankar
To add more clarity to my question

My data pp2 is a list 

 (pp2[[1]])
  RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price
ABCD.SZ   2008/02/29   15.30   CNY  0.1408
2.154240
ABCD.SZ   2008/01/31   15.27   CNY  0.1392
2.040048
ABCD.SZ   2007/11/30   11.07   CNY  0.1357
1.502199
ABCD.SZ   2007/10/31   10.89   CNY  0.1340
1.459260
ABCD.SZ   2007/09/28   12.77   CNY  0.1334
1.703518

 (pp2[[2]])
RIC  Trade.Date   Close.Price Currency.Code Convertion.Rate
New.Price
PQRS.SZ   2008/02/299.27   CNY 0.1408   1.305216
PQRS.SZ   2008/01/318.07   CNY 0.1392   1.123344
PQRS.SZ   2007/12/318.76   CNY 0.1371   1.200996
PQRS.SZ   2007/11/306.43   CNY 0.1357   0.872551
PQRS.SZ   2007/10/316.80   CNY 0.1340   0.911200
PQRS.SZ   2007/09/287.94   CNY 0.1334   1.059196

And so on till (pp2[[1244]])

Each of pp2[[i]] is a data frame. For each date I need to find the range
of New.Price across the list
i.e.for 2008/02/29   it would be
max(pp2[[i]]$New.Price[1])-min(pp2[[i]]$New.Price[1]) where i ranges
from 1 to 1244

Thank you,
Ravi

 
 
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 27, 2008 2:12 AM
To: Ravi S. Shankar
Subject: Re: [R] Range across a List

From: Ravi S. Shankar [EMAIL PROTECTED]
Date: 2008/03/26 Wed PM 03:28:52 CDT
To: [EMAIL PROTECTED]
Subject: [R] Range across a List

i think it's a dataframe ( it looks
like one )  or convert it to
one if it's not and then I think below should
work.

temp-lapply(split(pp2,pp2$Trade.Date), function(.df)
{
  data.frame(.df$Trade.Date[1],range(.df$New.Price))
})

result-do.call(rbind,temp)

test it though because i didn't.


Hi R,
I have a list
 class(pp2)
[1] list
 
 length(pp2)
[1] 1244

It is in the below format
  RIC Trade.Date Close.Price Currency.Code Convertion.Rate
New.Price
ABCD.SZ   2008/02/29   15.30CNY  0.1408  2.154240
ABCD.SZ   2008/01/31   15.27CNY  0.1392  2.125584
ABCD.SZ   2007/12/31   14.88CNY  0.1371  2.040048
ABCD.SZ   2007/11/30   11.07CNY  0.1357  1.502199
ABCD.SZ   2007/10/31   10.89CNY  0.1340  1.459260
ABCD.SZ   2007/09/28   12.77CNY  0.1334  1.703518

I want to find the range of pp2$New.Price for length(pp2) for each date
Any help would be appreciated

Thanks in advance
Ravi


This e-mail may contain confidential and/or privileged
i...{{dropped:10}}

__
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.

This e-mail may contain confidential and/or privileged i...{{dropped:10}}

__
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] Range across a List

2008-03-26 Thread Ravi S. Shankar
I did the following
DF-do.call(rbind, pp2)
DF1=na.omit(DF)
DF1[,2]=as.Date(DF1[,2])

str(DF)
'data.frame':   18660 obs. of  6 variables:

I tried the following code

temp-lapply(split(DF1,DF1$Trade.Date), function(.df) {
+
data.frame(DATE=.df$Trade.Date,RANGE=max(.df$New.Price)-min(.df$New.Pric
e))
+ })

temp[[1]][1:5,]
DATERANGE
1 2006-12-29 1276.670
2 2006-12-29 1276.670
3 2006-12-29 1276.670
4 2006-12-29 1276.670
5 2006-12-29 1276.670

What am I doing wrong?

I also tried the below and that seemed to give me the range

nn=tapply(DF1$New.Price, DF1$Trade.Date, range)

 head(nn)
$`2006-12-29`
[1]0.0074638 1276.6772880

$`2006-12-31`
[1]   4.673445 227.60

$`2007-01-31`
[1]0.0030772 1255.2080450

$`2007-02-28`
[1]0.003978 1316.638200

$`2007-03-29`
[1]   5.25585 216.2

$`2007-03-30`
[1]0.0047214 1266.825


Thanks

Ravi Shankar S 
 
 

-Original Message-
From: jim holtman [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 27, 2008 2:49 AM
To: Ravi S. Shankar
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [R] Range across a List

I think something like this should work.  I will give you the range
for each date across all the data:

x - do.call(rbind, pp2)
tapply(x$New.Price, x$Trade.Date, range)


On 3/26/08, Ravi S. Shankar [EMAIL PROTECTED] wrote:
 To add more clarity to my question

 My data pp2 is a list

  (pp2[[1]])
  RIC Trade.Date Close.Price Currency.Code Convertion.Rate
New.Price
 ABCD.SZ   2008/02/29   15.30   CNY  0.1408
 2.154240
 ABCD.SZ   2008/01/31   15.27   CNY  0.1392
 2.040048
 ABCD.SZ   2007/11/30   11.07   CNY  0.1357
 1.502199
 ABCD.SZ   2007/10/31   10.89   CNY  0.1340
 1.459260
 ABCD.SZ   2007/09/28   12.77   CNY  0.1334
 1.703518

  (pp2[[2]])
 RIC  Trade.Date   Close.Price Currency.Code Convertion.Rate
 New.Price
 PQRS.SZ   2008/02/299.27   CNY 0.1408
1.305216
 PQRS.SZ   2008/01/318.07   CNY 0.1392
1.123344
 PQRS.SZ   2007/12/318.76   CNY 0.1371
1.200996
 PQRS.SZ   2007/11/306.43   CNY 0.1357
0.872551
 PQRS.SZ   2007/10/316.80   CNY 0.1340
0.911200
 PQRS.SZ   2007/09/287.94   CNY 0.1334
1.059196

 And so on till (pp2[[1244]])

 Each of pp2[[i]] is a data frame. For each date I need to find the
range
 of New.Price across the list
 i.e.for 2008/02/29   it would be
 max(pp2[[i]]$New.Price[1])-min(pp2[[i]]$New.Price[1]) where i ranges
 from 1 to 1244

 Thank you,
 Ravi





 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Thursday, March 27, 2008 2:12 AM
 To: Ravi S. Shankar
 Subject: Re: [R] Range across a List

 From: Ravi S. Shankar [EMAIL PROTECTED]
 Date: 2008/03/26 Wed PM 03:28:52 CDT
 To: [EMAIL PROTECTED]
 Subject: [R] Range across a List

 i think it's a dataframe ( it looks
 like one )  or convert it to
 one if it's not and then I think below should
 work.

 temp-lapply(split(pp2,pp2$Trade.Date), function(.df)
 {
  data.frame(.df$Trade.Date[1],range(.df$New.Price))
 })

 result-do.call(rbind,temp)

 test it though because i didn't.


 Hi R,
 I have a list
  class(pp2)
 [1] list
 
  length(pp2)
 [1] 1244
 
 It is in the below format
   RIC Trade.Date Close.Price Currency.Code Convertion.Rate
 New.Price
 ABCD.SZ   2008/02/29   15.30CNY  0.1408  2.154240
 ABCD.SZ   2008/01/31   15.27CNY  0.1392  2.125584
 ABCD.SZ   2007/12/31   14.88CNY  0.1371  2.040048
 ABCD.SZ   2007/11/30   11.07CNY  0.1357  1.502199
 ABCD.SZ   2007/10/31   10.89CNY  0.1340  1.459260
 ABCD.SZ   2007/09/28   12.77CNY  0.1334  1.703518
 
 I want to find the range of pp2$New.Price for length(pp2) for each
date
 Any help would be appreciated
 
 Thanks in advance
 Ravi
 
 
 This e-mail may contain confidential and/or privileged
 i...{{dropped:10}}
 
 __
 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.

 This e-mail may contain confidential and/or privileged...{{dropped:30}}

__
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] Break up a data frame

2008-03-20 Thread Ravi S. Shankar
Hi R users,

 

I have a dataframe in the below format 

xyz   01/03/200715.25USD

xyz   01/04/200715.32USD

xyz   01/02/200823.22USD

abc   01/03/200745.2  EUR

abc   01/04/200745.00EUR

abc   01/02/200868.33EUR

 

I want to change the above data into the below format

 

 

xyz   01/03/200715.25USD abc
01/03/200745.2  EUR

xyz   01/04/200715.32USD abc
01/04/200745.00EUR

xyz   01/02/200823.22USD abc
01/02/200868.33EUR

 

Any help would be welcome

 

Thank you

 

Ravi

 

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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] Read in date fomat while colClasses=character

2007-10-09 Thread Ravi S. Shankar
Hi R users,

 

I am using xlsReadWrite to read a particular excel file. In one of the
columns I have dates ( say col=5). Now date column is read by default as
numeric. So I used dateTimeAs= isodatetime. This enables reading in
the date format. However in the earlier column (say col=1) I have data
which however starts from row 10. So to read data from column one I use
colClasses=character. But this overrules the isodatetime. 

Now is there someway I can read in date format while keeping
colClasses=character

 

Thanks for your help

 

Ravi 


[[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.