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

[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

Re: [R] Help on Select.list

2010-09-03 Thread Ravi S. Shankar
. 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

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

[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

[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

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

[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

[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])

[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

[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

[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] =

[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

Re: [R] Range across a List

2008-03-26 Thread Ravi S. Shankar
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

Re: [R] Range across a List

2008-03-26 Thread Ravi S. Shankar
-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

[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/2007

[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