[R] Identifying columns with specific character

2018-04-18 Thread Farnoosh Sheikhi via R-help
Hello, I have a data frame with 400 columns and wanted to filter character columns with "$" in it.For example: >  x <- c("$5", "$89", "$10", "$34")  >  y <- c(1:4)>  My.Data <- data.frame (x,y)> My.Data    x y1  $5 12 $89 23 $10 34 $34 4 I want to detect the columns with $ and remove the $ from t

[R] Fw: passing different sample sizes

2017-09-25 Thread Farnoosh Sheikhi via R-help
Hi,  I have the below function which returns confidence intervals. I wanted to pass different sample sizes through the function, but for some reason it's not working. n   <- seq(from=40, to=300, by=2o) I was also wondering how I can return a plot for different sample sizes.  plot(m~d, main="

Re: [R] Different date formats in one column

2017-06-29 Thread Farnoosh Sheikhi via R-help
Thanks Jeff. This is a nice way of solving this problem. What about the cases with 0015-02-21?Many thanks. Best,Farnoosh On Wednesday, June 28, 2017 10:49 PM, Jeff Newmiller wrote: I doubt your actual file looks like the mess that made it to my email software (below) because you

Re: [R] Different date formats in one column

2017-06-29 Thread Farnoosh Sheikhi via R-help
Hi Christoph, There is "," between dates.Many thanks. Best,Farnoosh On Wednesday, June 28, 2017 9:05 PM, Christoph Puschmann wrote: Hey, Are all the dates connected? So no comma or space btw? Regards, Christoph > On 29 Jun 2017, at 2:02 pm, Farnoosh Sheikhi via R-h

[R] Different date formats in one column

2017-06-28 Thread Farnoosh Sheikhi via R-help
Hi,  I have a data set with various date formats in one column and not sure how to unify it.Here is a few formats: 02091702/22/170221201703/17/160015-08-239/2/1500170806May-2-201522-March-2014 I tried parse_date_time from lubridate library but it failed.Thanks so much.  Best,Farnoosh

[R] unique dates per ID

2016-11-14 Thread Farnoosh Sheikhi via R-help
011-01-03" ,"2011-01-04", "2011-01-05", "2011-01-06" ,"2011-01-07", "2011-01-07", "2011-01-09" ,"2011-01-10"         ,"2011-01-11" ,"2011-01-11")deps<-c("A", "B&quo

[R] Extracting dates to create a new variable

2016-08-10 Thread Farnoosh Sheikhi via R-help
lt;- data.frame(Subject, dates, deps)df The final data set should look like this:newdate<-c(" 2011-01-03",   "2011-01-03",  "2011-01-03", "2011-01-05", "2011-01-05", "2011-01-05" , "2011-01-08", "2011-01-08", "201

[R] Extracting dates to create a new variable

2016-08-08 Thread Farnoosh Sheikhi via R-help
;C", "CC", "A", "F", "DD", "A", "F", "FF", "D")df <- data.frame(Subject, dates, deps)df The final data set should look like this:newdate<-c(" 2011-01-03",   "2011-01-0

[R] Merging Issue

2016-06-17 Thread Farnoosh Sheikhi via R-help
Hi all,  I have two data sets similar like below and wanted to merge them with variable "deps". As this is a sample data with small sample size, I don't have any problem using command merge. However, the actual data set has ~60,000 observations with a lot of repeated measures. For example, for a

Re: [R] Filtering based on the occurrence

2016-03-31 Thread Farnoosh Sheikhi via R-help
Hi Jim,  Thank you tons for your help. The code worked perfectly :) Best,Farnoosh On Wednesday, March 30, 2016 1:13 AM, Jim Lemon wrote: Hi Farnoosh, Despite my deep suspicion that this answer will solve a useless problem, try this: last_subject<-0 keep_deps<-c(&quo

[R] Filtering based on the occurrence

2016-03-29 Thread Farnoosh Sheikhi via R-help
te('2011-01-12'),by = 1) deps<-c("A", "B", "C", "C", "D", "A", "F", "G", "A", "F", "A", "D")df <- data.frame(Subject, dates, deps)df The final da

[R] Distance in miles btw Zipcodes

2015-09-17 Thread Farnoosh Sheikhi via R-help
 Hello, I'm trying to get the distances between two Zipcode variables, but for some reason I get this error: "matching was not perfect, returning what was found.Error: no such index at level 1" Here is my code: library(ggmap)mapdist(data$Zip.A, data$Zip.B, mode = "driving") The Zip codes are all

Re: [R] Mixed Date Formats

2015-07-30 Thread farnoosh sheikhi via R-help
last entries. I change my assessment : this looks bad. (Tea at hand). So, presumably Farnoosh may not be able to guarantee the formats for 3 & 4 either unless they are unambiguously dated. John Kane Kingston ON Canada > -Original Message- > From: sarah.gos...@gmail.com

Re: [R] Mixed Date Formats

2015-07-29 Thread farnoosh sheikhi via R-help
                                                                                                    -7L), class = "data.frame")SampleData Thanks for your help:).   On Wednesday, July 29, 2015 1:50 PM, Sarah Goslee wrote: On Wed, Jul 29, 2015 at 2:45 PM, farnoosh sheikhi v

[R] Mixed Date Formats

2015-07-29 Thread farnoosh sheikhi via R-help
 Hi Arun, Hope all is well with you. I have a data with a column for date.The date format is mixed. There are date values with Month/Day/Year format and values with Day/Month/Year format.I don't know how to unify it.I really appreciate your help.Thanks. [[alternative HTML version dele

Re: [R] Difference in dates for unique ID

2015-02-15 Thread farnoosh sheikhi via R-help
That's exactly what I was thinking. Thanks tons. Sent from Yahoo Mail on Android From:"arun" Date:Sun, Feb 15, 2015 at 2:47 AM Subject:Re: Difference in dates for unique ID HI Farnoosh, Not sure I understand the expected output.� The difference between the first 2 days is

Re: [R] Scatter plot for repeated measures

2014-12-08 Thread farnoosh sheikhi
Thank you all. That was very helpful.  Farnoosh On Saturday, December 6, 2014 7:41 PM, Chel Hee Lee wrote: It seems that you would like to make a spaghetti plot (in a longitudinal data analysis).  You can use the function 'interaction.plot()'. > with(my.df, int

Re: [R] Seprate last name and first name into two columns

2014-07-08 Thread farnoosh sheikhi
It actually worked perfectly. Thank you so much. I always learn a lot from you:).   Farnoosh On Monday, July 7, 2014 6:51 PM, arun wrote: Not sure this helps as you provided only very little info. library(stringr) str1 <- c("TE MA CRUZ  ABEL","JOSE  AN    ANDRA&

Re: [R] ggplot/ barplot

2014-02-27 Thread farnoosh sheikhi
You are the best. Thanks tons:))   Regards, Farnoosh Sheikhi On Thursday, February 27, 2014 10:37 PM, arun wrote: Hi Farnoosh, YOu can try:  DataA$percent <- with(DataA,round((Var2/sum(Var2))*100,2)) library(ggplot2)   ggplot(DataA,aes(x=Var1,y=percent))+geom_bar(stat="identity&q

[R] simulation of Hierarchical design

2014-02-24 Thread farnoosh sheikhi
, etc. I want to create a data set in R based on this story. I really appreciate any help and direction.    Regards, Farnoosh Sheikhi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r

Re: [R] Mapping two data files

2014-02-20 Thread farnoosh sheikhi
Thank you so much Arun:)   On Wednesday, February 19, 2014 6:06 PM, arun wrote: Hi Farnoosh, Try: library(plyr) res <- join(`DATA-A`,`DATA-B`,by="Var1",type="right")[,c(3,1:2,4)]  head(res) #  ID   Var1   Var2 var3 #1  1 AETNA CARDINAL CA

Re: [R] Changing Character Value

2014-02-13 Thread farnoosh sheikhi
Perfect. Thank you so much.   Regards, Farnoosh Sheikhi On Thursday, February 13, 2014 2:16 PM, arun wrote: Hi Farnoosh, If I understand it correctly, dat <-read.table(text="Var1 Great>5 great 'less great<2' 'approx great11'",sep="",head

Re: [R] Aggregation

2014-02-13 Thread farnoosh sheikhi
Thanks:)   Regards, Farnoosh Sheikhi On Thursday, February 13, 2014 1:29 PM, arun wrote: Sorry, the library should be library(reshape2) On Thursday, February 13, 2014 4:27 PM, arun wrote: HI Farnoosh, You can use ?dcast() library(plyr)  dcast(DataA,ID~Var1,value.var="Var2&qu

Re: [R] list to data frame

2013-08-28 Thread farnoosh sheikhi
Thanks a lot. That worked perfectly.   Best,Farnoosh Sheikhi Sent: Wednesday, August 28, 2013 10:37 AM Subject: Re: list to data frame If the expected result is data.frame()  as.data.frame(t(as.data.frame(lapply(dat1,sum# would be data.frame.  But, not

Re: [R] Loop for converting character columns to Numeric

2013-08-26 Thread farnoosh sheikhi
Thanks a lot. That works great. I have another question, I will send you another email.   Best,Farnoosh Sheikhi Cc: R help Sent: Monday, August 26, 2013 12:06 PM Subject: Re: Loop for converting character columns to Numeric Hi, Suppose you created a

Re: [R] changing colnames

2013-08-14 Thread farnoosh sheikhi
Thanks for the code. It was so simple and worked perfectly. I really appreciate it.   Best,Farnoosh Sheikhi Cc: R help Sent: Wednesday, August 14, 2013 11:56 AM Subject: Re: changing colnames Hi, You could try: dat1<- read.table(text=" X1,X2,X3

Re: [R] Aggregate

2013-07-29 Thread farnoosh sheikhi
Thanks a lot Arun.  I like the do.call command a lot. So easy to use and fast:-)   Best,Farnoosh Sheikhi Cc: R help Sent: Monday, July 29, 2013 1:58 PM Subject: Re: Aggregate Hi, You could try: dat1<- read.table(text=" ID     Group1 1     1 1

Re: [R] subtracting rows for unique

2013-07-24 Thread farnoosh sheikhi
te x2 x1      x3 56 25-Jun-01 10 2 126 56 29-Oct-01 10 2 140 56 18-Mar-02 10 2 445 56 6-Jun-03 10 2 224 56 16-Jan-04  NA             NA 58 10-Jan-02 10.8 1 715 58 26-Dec-03 10.8 1             NA Best,Farnoosh Sheikhi  [[alternative HTML version deleted]]

[R] Markov Chain Discrete

2013-05-05 Thread farnoosh sheikhi
Hi, I want to simulate from Markov Chain Discrete Algorithm and my transition  matrix is: The probability transition matrix trans = matrix(c(0.8,0.05,0.05,0,                  0.05,0.80,0.055,                  0.05,0.05,0.81, 0, 0.05, 0.095, 0, 0.81), ncol=4, byrow=TRUE); The Initiate Values are

Re: [R] Excluding observations

2013-04-21 Thread farnoosh sheikhi
Thanks a lot. That worked:-) Cc: R help Sent: Sunday, April 21, 2013 7:32 AM Subject: Re: Excluding observations Hi Farnoosh, set.seed(25) Data.All.Var<- data.frame(ID= sample(LETTERS[1:10],25,replace=TRUE), value=rnorm(25),stringsAsFactors=FA

Re: [R] Merge

2013-04-17 Thread Farnoosh
Thanks a lot:) Sent from my iPad On Apr 16, 2013, at 10:15 PM, arun wrote: > Hi Farnoosh, > YOu can use either ?merge() or ?join() > DataA<- read.table(text=" > ID v1 > 1 10 > 2 1 > 3 22 > 4 15 > 5 3 > 6 6 > 7

Re: [R] Comparison of Date format

2013-04-13 Thread farnoosh sheikhi
New[3,] & x2[i,2]< x1New[4,] ,]; x4<-x2[i,][nrow(x3)>0];merge(x3[,1:2],x4) }))})) dataNew2$Date.Accident<-format(dataNew2$Date.Accident,"%d-%b-%y") library(plyr) res<-join(rbind(dataNew1,dataNew2),DataB,by=c("ID","Date.Accident"),type="rig

[R] Pivot

2013-01-28 Thread farnoosh sheikhi
        00  1 Thanks. Best,Farnoosh Sheikhi [[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

[R] GLM ERROR

2012-12-22 Thread farnoosh sheikhi
!!! I'm wondering if there is something wrong in my codes . Thanks a lot and happy holidays!   Best,Farnoosh Sheikhi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help P

[R] Subset of Data

2012-12-12 Thread farnoosh sheikhi
olumn my lab or procedures start. I really appreciate your help. Thanks.   Best,Farnoosh Sheikhi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

Re: [R] Subset of Data

2012-12-12 Thread farnoosh sheikhi
Thank you so much. It worked very well:)   Best,Farnoosh Sheikhi Cc: R help Sent: Wednesday, December 12, 2012 12:59 PM Subject: Re: Subset of Data Hi Farnoosh, Try this: set.seed(151) mat1<-matrix(sample(1:400,100,replace=TRUE),ncol=20) set.seed

[R] Step-wise method for large dimension

2012-11-15 Thread farnoosh sheikhi
mydata) ??? step(fit0, scope=list(lower=fit0, upper=fit.final), data=mydata, direction="forward") step(fit.final, scope=list(lower=fit.final, upper=fit0), data=mydata, direction="backward")   Best,Farnoosh Sheikhi [[alternative HTML version deleted]] ___

Re: [R] for loop

2012-11-13 Thread farnoosh sheikhi
thanks dear. method 2 worked very fast since my data is very big. Thanks a lot. :-)   Best,Farnoosh Sheikhi Cc: R help Sent: Monday, November 12, 2012 6:15 PM Subject: Re: for loop HI, You can do this in many ways: dat1<-read.table(text=" med1,m

[R] reshape

2012-11-12 Thread farnoosh sheikhi
Hi, I have a R output that looks as follow: Rad:0 Rad1:2 Rad3:3 I want to make a new matrix that looks like : sample size is 2400 Variable    n11  n12 Rad            0     2400-0=2400 Rad1          2       2400-2 Rad3  3      2400-3   Thanks a lot for your time and help:) Best,Farnoosh Sheikhi

Re: [R] pivot table

2012-11-07 Thread farnoosh sheikhi
I'm using Revolution R Enterprise. This command worked perfectly. Thank you so much for your help and time:-)   Best,Farnoosh Sheikhi Cc: R help Sent: Wednesday, November 7, 2012 10:47 AM Subject: Re: [R] pivot table HI, Could you tell me which version

Re: [R] pivot table

2012-11-07 Thread farnoosh sheikhi
Hi there, Thanks forhelping. I really appreciate it. The only thing is I get this error: "Error in gsub("[\\_]", ".", paste0("Lab", colnames(res2)[-1])) :    could not find function "paste0"" Thanks.   Best,Farnoosh Sheikhi ___

Re: [R] pivot table

2012-11-06 Thread farnoosh sheikhi
It worked beautifully. Thank you so much:-)   Best,Farnoosh Sheikhi Cc: R help Sent: Tuesday, November 6, 2012 2:44 PM Subject: Re: [R] pivot table Hi, Is this okay? library(reshape2) dat1<-read.table(text=" ID   Diag   Proc  DOB  Gender   a 

Re: [R] pivot table

2012-11-06 Thread farnoosh sheikhi
Hi there, Thanks a lot for your help, but Proc doesn't show in the result. I also want to assign 1 and 0 instead of the name of variables. Thanks a lot.   Best,Farnoosh Sheikhi Cc: R help Sent: Tuesday, November 6, 2012 1:42 PM Subject: Re: [R] pivot

Re: [R] pivot table

2012-11-06 Thread farnoosh sheikhi
   Lab3.A a           11       1000 b    0    1001               0 Thanks a lot:) Best,Farnoosh Sheikhi Cc: R help Sent: Tuesday, November 6, 2012 2:44 PM Subject: Re: [R] pivot table Hi, Is this okay? library(reshape2) dat1<-read.table(text=" ID   Dia

[R] pivot table

2012-11-06 Thread farnoosh sheikhi
                           diag1 I want to reformat this data to : ID   diag1 diag 2 diag 3..  diagx   proc1   proc2   proc3... procx  DOB  Gender a1011  20F Thanks a lot for your help and time.   Best,Farnoosh Sheikhi [[alternative HTML version deleted]] __ R-help@r

Re: [R] frequency

2012-10-23 Thread farnoosh sheikhi
Thanks a lot. Is count command in package COUNT? I'm having a hard fine to fine this package. Thanks again:)   Best,Farnoosh Sheikhi Cc: R help Sent: Tuesday, October 23, 2012 2:07 PM Subject: Re: [R] frequency Hi, Try this: dat1<-read.table(t

[R] frequency

2012-10-23 Thread farnoosh sheikhi
hanks a lot. Best,Farnoosh Sheikhi [[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 comm

[R] library(rmeta)

2012-10-15 Thread farnoosh sheikhi
form. When I put odds.ratio=as.matrix(odds.ratio), my plot shows the numbers. I really appreciate your help. Thanks. Best,Farnoosh Sheikhi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listi

[R] converting DOB format to age

2012-10-08 Thread farnoosh sheikhi
Hi, I have a column of DOB in mm/dd/. I want to convert this format to age. Thanks a lot.   Best,Farnoosh Sheikhi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

[R] Converting array to matrix

2012-09-28 Thread farnoosh sheikhi
50 100 0.9647998 >    Best,Farnoosh Sheikhi [[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 an