[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
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 "136 days" May be