[R] How to extract the theta values from coxph frailty models
Hello, I am working on the frailty model using coxph function. I am running some simulations and want to store the variance of frailty (theta) values from each simulation result. Can anyone help me how to extract the theta values from the results. I appreciate any help. Thanks Shankar Viswanathan __ 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] Saving tab/csv delimited data with NaN's
Hello, I am working multiple simulated data sets with missing values, I would like to store these data sets in either tab delimited format for .csv format with missing values marked as NaN's instead of NA's. I read the import/export document which mentions that write.table command converts NaN's to NA. Is there any other way I can store the NaN's. I tried the write syntax it gives me error codes. Each data files are of dimensions 1000 x 21 . I would appreciate any help in this regard. Many thanks __ 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] R 2.10 Read/write.table
Hello, Recently I installed R version 2.10 from 2.9.2 and after the update some the commands like write.table is not functioning properly. Does anyone has similar issues. Am I missing something ? Say for example I generated a simulation data (simd1) and used this syntax to store it write.table(simd1, file="simdg10050", sep=",") the data does not get stored as needed all it creates is a file simdg10050 with quotes. However when I run the same codes in versions 2.9.2 below I get the required results. Can any one help in this regard. I really appreciate your help. Thanks Shankar __ 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] How to predict time series high-frequency data?
Hi All, I am having very high-frequency data, captured between 3 to 7 seconds by sensor for tank. Number of rows of data point are 7 million and its multivariate problem. Due to high frequency data, time series is unable to capture frequency & Cycle of data. Please help me, how to approach and which kinds of algorithm required to solve this problem using R. Thanks, Rama Shankar [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] How to threshold point in time series
Hi All, I am having very high-frequency data, captured between 3 to 7 seconds by sensor for liquid tank and capacity of tank is 50k dm3. When tank capacity reduce to 1k dm3, than tank refilling need to call. How in time series we can perform, refilling can call when tank capacity reduce to 1k dm3, and how to find 1k dm3 as threshold point and repeat the process. Please help me, how to approach and which kinds of algorithm required to solve this problem using R/ python. Thanks.. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] How to extract the theta values from coxph frailty models
Hello, I am working on the frailty model using coxph functions. I am running some simulations and want to store the variance of frailty (theta) values from each simulation result. Can anyone help me how to extract the theta values from the results. I appreciate any help. Thanks Shankar Viswanathan __ 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] Saving tab/csv delimited data with NaN's
Thank you a ton - this simplifies my work considerably.- Shankar Rolf Turner wrote: On 24/03/2010, at 9:50 AM, shan...@bios.unc.edu wrote: Hello, I am working multiple simulated data sets with missing values, I would like to store these data sets in either tab delimited format for .csv format with missing values marked as NaN's instead of NA's. I read the import/export document which mentions that write.table command converts NaN's to NA. Is there any other way I can store the NaN's. I tried the write syntax it gives me error codes. Each data files are of dimensions 1000 x 21 . I would appreciate any help in this regard. A feasible workaround is to convert your data to character before writing them. Suppose that your data are in a data frame called ``clyde''. Set mung <- as.data.frame(lapply(clyde,as.character)) write.csv(mung,"mung.csv",row.names=FALSE,quote=FALSE) # Check: gorp <- read.csv("mung.csv") all.equal(gorp,clyde) [1] TRUE HTH cheers, Rolf Turner ## Attention: This e-mail message is privileged and confidential. If you are not the intended recipient please delete the message and notify the sender. Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshal www.marshalsoftware.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.
[R] Boxplot for X Vs Y variable grouped by ID
Dear All, I am new to R. I amazed by this software. I have a question regarding boxplot. I have three columns say X, Y,ID (X is time from 0 to 12 hrs, Y is a variable dependent on X) I can plot a simple boxplot if it is just one group. But I have 10 groups and I want to plot all of them in one graphs. Something like multiple boxplots in one graph. I am not in R mailing list please reply to me directly. Thank you very much for your help. -- Regards, Shankar Lanke Ph.D. University at Buffalo Office # 716-645-4853 Fax # 716-645-2886 Cell # 678-232-3567 [[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] Identifying the particular X or Y in a sorted list
Dear All, I have a data sets as shown below A (Patient ID ), B and C are the Concentration of drug in blood on day 1 and day 4, D is the difference in conc. To do this in R I have written a code as follows, identified the number of patients who have more concentration on day 4 . Here I want to identify specifically the patient ID (is he patient 1 or 2 or 5 and 7), whose concentration is more. How to write a code to get the list of A (patient ID whose difference is more on day 4). Data<-(myDf$B-myDf$C) sum(Data>0) A B CD (B-C) 1 14 10 4 2 12 7 5 3 11 15 -4 4 8 3 5 5 1 8 -7 I appreciate your help, thank you very much in advance. Regards [[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] Identifying the particular X or Y in a sorted list
Dear All, I have a data sets as shown below A (Patient ID ), B and C are the Concentration of drug in blood on day 1 and day 4, D is the difference in conc. To do this in R I have written a code as follows, identified the number of patients who have more concentration on day 4 . Here I want to identify specifically the patient ID (is he patient 1 or 2 or 5 and 7), whose concentration is more. How to write a code to get the list of A (patient ID whose difference is more on day 4). Data<-(myDf$B-myDf$C) sum(Data>0) ABCD (B-C)1141042127531115-44835518-7 I appreciate your help, thank you very much in advance. Regards [[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] Identifying the particular X or Y in a sorted list
Dear All, Thank you very much in advance. I have a data sets as shown below A (Patient ID ), B and C are the Concentration of drug in blood on day 1 and day 4, D is the difference in conc. To do this in R I have written a code as follows, identified the number of patients who have more concentration on day 4 . Here I want to identify specifically the patient ID (is he patient 1 or 2 or 5 and 7), whose concentration is more. How to write a code to get the list of A (patient ID whose difference is more on day 4). A 1 2 3 4 5 B 7 2 3 6 9 C 4 6 9 2 5 (B-C) 3 -4 -6 4 4 DF1<-list(A,B,C) DF1 DF2<-(DF1$C-DF1$B) length(DF2) sum(DF2>0) #I want to subtract B from C to see and identify how many patients have greater concentrations and who are these patients (A). On Thu, May 3, 2012 at 12:15 PM, John Kane wrote: > You do not seem to have suppied either code nor data. Please supply both. > > John Kane > Kingston ON Canada > > > > -Original Message- > > From: shankarla...@gmail.com > > Sent: Wed, 2 May 2012 22:06:54 -0400 > > To: r-help@r-project.org > > Subject: [R] Identifying the particular X or Y in a sorted list > > > > Dear All, > > > > I have a data sets as shown below A (Patient ID ), B and C are the > > Concentration of drug in blood on day 1 and day 4, D is the difference in > > conc. To do this in R I have written a code as follows, identified the > > number of patients who have more concentration on day 4 . Here I want to > > identify specifically the patient ID (is he patient 1 or 2 or 5 and 7), > > whose concentration is more. > > How to write a code to get the list of A (patient ID whose difference is > > more on day 4). > > > > Data<-(myDf$B-myDf$C) > > sum(Data>0) > > > > A B CD (B-C) 1 14 10 4 2 12 7 5 3 11 15 -4 4 8 3 5 5 1 8 -7 > > > > I appreciate your help, thank you very much in advance. > > > > Regards > > > > [[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. > > ________ > GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at > http://www.inbox.com/smileys > Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk and > most webmails > > > -- Regards, Shankar Lanke Ph.D. Assistant Professor Department of Pharmaceutical Sciences College of Pharmacy The University of Findlay (C) 678-232-3567 (O) 419-434-5448 Fax# 419-434-4390 [[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] Identifying the particular X or Y in a sorted list
Dear John, Thank you very much for your response, I appreciate your input. I am able to subtract the two columns, (B - C) , the subset information I need is how many "A"s and who are the "A". For example P,Q,R,S,T, persons earned $ 7, 2, 3, 6, 9 in 1 st month and $ 4, 6, 9, 2, 5 in 2nd month. I want to identify who earned more on 1st month + the difference (only if it is positive). In this case P,S,T earned $3,4,4, in 2nd month. mydata <- data.frame( a = c(1, 2, 3, 4 , 5), b = c(7, 2, 3, 6, 9), c = c(4, 6, 9, 2, 5)) mydata$d <- mydata$b - mydata$c mydata subset(mydata, mydata$d ==max(mydata$d)) On Thu, May 3, 2012 at 2:47 PM, John Kane wrote: > ** > I'm sorry, it's still not clear what you are doing but perhaps this is > close? > > mydata <- data.frame( a = c(1, 2, 3, 4 , 5), b = c(7, 2, 3, 6, 9), c = > c(4, 6, 9, 2, 5)) > mydata$d <- mydata$b - mydata$c > mydata > subset(mydata, mydata$d ==max(mydata$d)) > > > > John Kane > Kingston ON Canada > > > -Original Message- > *From:* shankarla...@gmail.com > *Sent:* Thu, 3 May 2012 14:14:17 -0400 > *To:* jrkrid...@inbox.com > *Subject:* Re: [R] Identifying the particular X or Y in a sorted list > > Dear All, > Thank you very much in advance. > > I have a data sets as shown below A (Patient ID ), B and C are the > Concentration of drug in blood on day 1 and day 4, D is the difference in > conc. To do this in R I have written a code as follows, identified the > number of patients who have more concentration on day 4 . Here I want to > identify specifically the patient ID (is he patient 1 or 2 or 5 and 7), > whose concentration is more. > How to write a code to get the list of A (patient ID whose difference is > more on day 4). > > > A 1 2 3 4 5 > B 7 2 3 6 9 > C 4 6 9 2 5 > (B-C) 3 -4 -6 4 4 > > DF1<-list(A,B,C) > DF1 > > DF2<-(DF1$C-DF1$B) > length(DF2) > sum(DF2>0) > > #I want to subtract B from C to see and identify how many patients have > greater concentrations and who are these patients (A). > > > On Thu, May 3, 2012 at 12:15 PM, John Kane wrote: > > You do not seem to have suppied either code nor data. Please supply both. > > John Kane > Kingston ON Canada > > > > -Original Message- > > From: shankarla...@gmail.com > > Sent: Wed, 2 May 2012 22:06:54 -0400 > > To: r-help@r-project.org > > Subject: [R] Identifying the particular X or Y in a sorted list > > > > Dear All, > > > > I have a data sets as shown below A (Patient ID ), B and C are the > > Concentration of drug in blood on day 1 and day 4, D is the difference in > > conc. To do this in R I have written a code as follows, identified the > > number of patients who have more concentration on day 4 . Here I want to > > identify specifically the patient ID (is he patient 1 or 2 or 5 and 7), > > whose concentration is more. > > How to write a code to get the list of A (patient ID whose difference is > > more on day 4). > > > > Data<-(myDf$B-myDf$C) > > sum(Data>0) > > > > A B CD (B-C) 1 14 10 4 2 12 7 5 3 11 15 -4 4 8 3 5 5 1 8 -7 > > > > I appreciate your help, thank you very much in advance. > > > > Regards > > > > [[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. > > > GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at > http://www.inbox.com/smileys > Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk and > most webmails > > > > > > -- > Regards, > Shankar Lanke Ph.D. > Assistant Professor > Department of Pharmaceutical Sciences > College of Pharmacy > The University of Findlay > (C) 678-232-3567 > (O) 419-434-5448 > Fax# 419-434-4390 > > -- > Free Online Photosharing - Share your photos online with your friends > and family! > Visit http://www.inbox.com/photosharing to find out more! > -- Regards, Shankar Lanke Ph.D. Assistant Professor Department of Pharmaceutical Sciences College of Pharmacy The University of Findlay (C) 678-232-3567 (O) 419-434-5448 Fax# 419-434-4390 [[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] Reading CSV file with unequal record length
Hello , I am having some difficulty reading a CSV file of unequal record length in R . The data has 26 columns and do not have header and is generated from a R syntax - write.table(schat,"schat.csv", sep=",", col.names=FALSE, append = TRUE) 1.0,1.0,0.0,0.1,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.5,1.9,2.7 1.0,2.0,0.0,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.5,0.5,0.6,0.7,0.8,0.9,1.1,1.2,1.4,1.6,1.9,2.2,2.7,,, 1.0,3.0,0.0,0.1,0.1,0.2,0.2,0.3,0.4,0.4,0.5,0.6,0.7,0.8,1.0,1.2,1.4,1.7,2.1,3.1,5.0, 1.0,4.0,0.0,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.5,0.6,0.7,0.7,0.9,1.0,1.2,1.4,1.7,2.2,3.0, 1.0,5.0,0.0,0.1,0.1,0.2,0.2,0.3,0.4,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.4,1.6,1.9,2.4,3.3 1.0,6.0,0.0,0.1,0.1,0.1,0.2,0.2,0.3,0.4,0.4,0.5,0.6,0.7,0.8,0.9,1.1,1.3,1.7,2.1,3.4, 1.0,7.0,0.0,0.1,0.1,0.2,0.3,0.3,0.4,0.5,0.5,0.6,0.7,0.8,0.9,1.1,1.2,1.4,1.7,2.0,2.5,3.3,5.5,,, 1.0,8.0,0.0,0.1,0.1,0.2,0.2,0.2,0.3,0.4,0.4,0.5,0.6,0.6,0.7,0.8,0.9,1.0,1.2,1.3,1.5,1.7,2.0,2.3,2.8,4.2 1.0,9.0,0.0,0.1,0.1,0.1,0.2,0.2,0.3,0.4,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.4,1.6,1.9,2.2,2.9,4.2,, 1.0,10.0,0.0,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.5,0.6,0.8,1.0,1.3,1.6,2.4,3.6,6.0,,, when I use the following syntax to read the above written data schat_n<-data.frame(read.table("schat.csv", sep=",", header = FALSE, fill=TRUE)) the data is fine until record # 7 but it gets wrapped on id 8 & 9 and limits the column to 23 and remaining values are made into second record as shown below with 12 records instead 10 1.0,1.0,1.0,0.0,0.1,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.5,1.9,2.7,NA 2.0,1.0,2.0,0.0,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.5,0.5,0.6,0.7,0.8,0.9,1.1,1.2,1.4,1.6,1.9,2.2,2.7 3.0,1.0,3.0,0.0,0.1,0.1,0.2,0.2,0.3,0.4,0.4,0.5,0.6,0.7,0.8,1.0,1.2,1.4,1.7,2.1,3.1,5.0,NA,NA 4.0,1.0,4.0,0.0,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.5,0.6,0.7,0.7,0.9,1.0,1.2,1.4,1.7,2.2,3.0,NA,NA 5.0,1.0,5.0,0.0,0.1,0.1,0.2,0.2,0.3,0.4,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.4,1.6,1.9,2.4,3.3,NA 6.0,1.0,6.0,0.0,0.1,0.1,0.1,0.2,0.2,0.3,0.4,0.4,0.5,0.6,0.7,0.8,0.9,1.1,1.3,1.7,2.1,3.4,NA,NA 7.0,1.0,7.0,0.0,0.1,0.1,0.2,0.3,0.3,0.4,0.5,0.5,0.6,0.7,0.8,0.9,1.1,1.2,1.4,1.7,2.0,2.5,3.3,5.5 8.0,1.0,8.0,0.0,0.1,0.1,0.2,0.2,0.2,0.3,0.4,0.4,0.5,0.6,0.6,0.7,0.8,0.9,1.0,1.2,1.3,1.5,1.7,2.0 9.0,2.3,2.8,4.2,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA 10.0,1.0,9.0,0.0,0.1,0.1,0.1,0.2,0.2,0.3,0.4,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.4,1.6,1.9,2.2,2.9 11.0,4.2,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA 12.0,1.0,10.0,0.0,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.5,0.6,0.8,1.0,1.3,1.6,2.4,3.6,6.0,NA,NA,NA,NA I would like the dataset to be read as is with 10 records and 26 columns, any inputs to get this fixed is greatly appreciable. Thank you in advance. Shankar -- ### University of North Carolina-Chapel Hill Department of Biostatistics 3101 McGavran-Greenberg, CB#7420 Chapel Hill, North Carolina 27599-7420 Phone: 919-843-1532 ### __ 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] Overloading in R
I have been trying to write a new class that reimplements the vector class. As a test of my overloading I decided to try and and call t.test on two vectors which were objects of my class rather than the default class. The overloaded length I wrote seems to work correctly. I used setMethod("length", "myvector", ...) setMethod("mean", "myvector", ...) setMethod("var", "myvector", ...) and created an object myv <- new("myvector",...) and when I called t.test(myv, myv) it first failed in the line mx <- mean(x) with the error that "x is not atomic I finally worked around by doing "mean.myvector" <- function(x, ...) { I now get the same error in the next line vx <- var(x) I tried doing "var.myvector" <- function(x,) as well as "var.myvector" <- function(x, y=NULL, na.rm=FALSE, use) all to no luck from within R I see the following > showMethods("var") Function "var": > var function (x, y = NULL, na.rm = FALSE, use) { .. } I *think* I understand that this has something to do with the fact that no generic function is declared for var so my function is not getting dispatched but with my limited knowledge of R I wasnt able to get setGeneric to work... Any suggestions? Apologies if this is answered somewhere else. Thanks, Shrikanth __ 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
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] skip for loop
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
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] write text file as output without quotes
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] combine words and dataframe
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] (no subject)
Dear Team, I am getting the following error message when try to run vb application The program was running fine in 32 windows 7 machine. When i moved the same program to 64 bit windows 8 machine i am getting the following error Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object 'C:/Program Files/R/R-2.15.1/library/stats/libs/i386/stats.dll': LoadLibrary failure: The specified module could not be found. During startup - Warning message:package 'stats' in options("defaultPackages") was not found [[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] Barplots
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] Help on Select.list
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
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] Help on write.xlsx library(xlsx)
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] Break up a data frame
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] Replace with previous value
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
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
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
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.8250000 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] Help with CrossTable
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] Time Interval calculation using R
Hi I have two columns of data with time in form of HH:MM:SS - representing start time and end time of an activity. I am trying to calculate the time difference (duration of the activity). (1) I first tried > difftime(btime, etime, units = "mins") This however gave me the error - Error in as.POSIXlt.character(as.character(x)) : character string is not in a standard unambiguous format (2) The above error message indicated some problem in format. So I tried > etime1=as.date(etime, %H:%M:%S") This gave me the Error: unexpected SPECIAL in "etime1=as.date(etime, %H:%" I also tried >etime1=format(etime, %H:%M:%S") But this gave a similar error - unexpected SPECIAL in "etime1=format(etime, %H:%" Any suggestions? Regards [[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] convert matrix to dataframe with repeating row names
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] Read in date fomat while colClasses="character"
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.
[R] lattice xyplot strip colors and location
Hi all, I've been trying (unsuccessfully) to modify an xyplot I created using the lattice package. I would like to change default strip colors and locations. I started with numeric data in 4 columns, which look like this: 0.252 1 32 0.252 2 30 0.252 3 27 0.252 4 23 0.252 5 17 0.253 1 30 0.253 2 29 0.253 3 26 0.253 4 21 0.253 5 15 0.5 2 1 23 0.5 2 2 23 0.5 2 3 22 0.5 2 4 18 0.5 2 5 15 0.5 3 1 22 0.5 3 2 22 0.5 3 3 21 0.5 3 4 16 0.5 3 5 13 Here's what I've done so far: library(lattice) plotdata <- read.table(file="data.txt", header=FALSE) attach(plotdata) frac.f <- factor(V1) stdev.f <- factor(V2) levels(frac.f) <- paste("f=",levels(frac.f), sep="") levels(stdev.f) <- paste("s=", levels(stdev.f), sep="") xyplot(V4~V3|frac.f*stdev.f, aspect=3/4, xlab="Reads as evidence", ylab="Total incorrect") detach(plotdata) Conditional variable values now appear as two stacked strips at the top of each panel. I'd like to move one to the left and also change strip colors. I tried the following but it didn't produce the desired result xyplot(V4~V3|frac.f*stdev.f, aspect=3/4, xlab="Min number of reads", ylab="Number of misjoins", strip=strip.custom(which.given=1, bg="skyblue"), strip.left=strip.custom(which.given=2,bg="yellow")) This changes the colors but also does the following - positions the left strips slightly away from the respective panels - all strip labels and values reflect only one conditional variable (s=2, s=3, etc.) Any help would be much appreciated Thanks, Shankar Postdoctoral Fellow National Human Genome Research Institute NIH Bethesda, MD __ 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.