[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
format="%B-%d-%y" ) idx <- grepl( "^(0[1-9]|1[0-2])[0-9]{2}[0-9]{2}$", dta$DtStr, perl=TRUE ) dta$Dt[ idx ] <- as.Date( dta$DtStr[ idx ], format="%m%d%y" ) idx <- grepl( "^([1-9]|1[0-2])/[0-9]{1,2}/[0-9]{2}$", dta$DtStr, perl=TRUE ) dta$Dt[ idx ] &l

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

[R] unique dates per ID

2016-11-14 Thread Farnoosh Sheikhi via R-help
Hi,  I have a data set like below: Subject<- c("2", "2", "2", "3", "3", "3", "4", "4", "5", "5", "5", "5")dates<-c("2011-01-01", "2011-01-01", "2011-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<-

[R] Extracting dates to create a new variable

2016-08-10 Thread Farnoosh Sheikhi via R-help
blockquote, div.yahoo_quoted { margin-left: 0 !important; border-left:1px #715FFA solid !important; padding-left:1ex !important; background-color:white !important; } Hi  I have a data set like below and wanted to create a new date variable by extracting the dates for specific departments.I wa

[R] Extracting dates to create a new variable

2016-08-08 Thread Farnoosh Sheikhi via R-help
Hi there,  I have a data set like below and wanted to create a new date variable by extracting the dates for specific departments.I want to extract the dates for departments CC, DD, FF,  put it in a new column and repeat it for other unique IDs. Subject<- c("2", "2", "2", "3", "3", "3", "4", "4"

[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
g) keep_rows<-c(keep_rows,rowindex) } final<-matrix(unlist(lapply(df[keep_rows,],as.character)),ncol=3) I find it terribly hard to ignore puzzles. Jim On Wed, Mar 30, 2016 at 10:52 AM, Farnoosh Sheikhi via R-help wrote: > Hello, > I have a data set similar to below and I wanted to

[R] Filtering based on the occurrence

2016-03-29 Thread Farnoosh Sheikhi via R-help
Hello,  I have a data set similar to below and I wanted to keep the observations after the first occurrence of these department: "B", "D", "F".For example for ID=2, the observation with deps=B and anything after will be kept in the data. For ID=3, observations with deps=D and anything after will

[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
13L, 8706L, 4049L, 5877L, >>> 1375L, 2223L, 3423L), date = structure(c(4L, 3L, 2L, 1L, 7L, >>> 6L, 5L), .Label = c("05/12/11", "06/05/11", "07-Dec-11", >>> "19-Dec-11", "01/22/2011", "10/19/2011", "31/12/20

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
2� 1� 0� 0 � � 2:� 2� � 3� 0� 1� 1 On Wednesday, February 11, 2015 5:47 PM, farnoosh sheikhi wrote: Hi Arun, I have a data set that look s like below. I wanted to get a difference in dates for each unique ID and record it as a new X and have binary input for each one. ID� Date 1� � � �

Re: [R] Scatter plot for repeated measures

2014-12-08 Thread farnoosh sheikhi
7;), type='l', col=1:3, ylab='X', > xlab='TIME') > legend('bottomright', inset=.05, legend=LETTERS[1:3], pch=1, col=1:3) > A.K. > > On Friday, December 5, 2014 5:45 PM, farnoosh sheikhi > wrote: > > > > Hi Arun, > > I hope you a

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

2014-07-08 Thread farnoosh sheikhi
quot;,"AL    MIGUEL","ALV", "Farnoosh  Sheikhi", "D  Art", "Rob K Kim") do.call(rbind,lapply(str_split(str_replace_all(str1,perl('(?<= )([A-Za-z]+)$'), ",\\1"),","),function(x) {x1 <- str_trim(x); if(length(

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
RE TIER 2      10 #2  2  AETNA EPO Group1  110 #3  3 BLUE CARD INTE Group1    2 #4  4    BLUE CROSS AUTO Group1   25 #5  5  BLUE CROSS CA Group1   33 #6  6   LOCKHEED Group2   40 A.K. On Wednesday, February 19, 2014 6:03 PM, farnoosh sh

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=FALSE) set.seed

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