[R] Regular Expression

2012-07-24 Thread Fred G
Hi-- I have three columns in an input file: MONTH QUARTER YEAR 2012-07 2012-32012 2001-07 2001-32001 2002-01 2002-12002 I want to make output like so: MONTH QUARTER YEAR 07 32012 07 32001 01 1

Re: [R] Regular Expression

2012-07-24 Thread Fred G
Thank you! :) On Tue, Jul 24, 2012 at 1:42 PM, Sarah Goslee wrote: > To delete everything from the beginning of the string to and including > the hyphen, use > sub("^.*-", "", tmp) > > Sarah > > On Tue, Jul 24, 2012 at 1:36 PM, Fred G wrote: > >

[R] Regular Expressions + Matrices

2012-08-10 Thread Fred G
Hi all, My code looks like the following: inname = read.csv("ID_error_checker.csv", as.is=TRUE) outname = read.csv("output.csv", as.is=TRUE) #My algorithm is the following: #for line in inname #if first string up to whitespace in row in inname$name = first string up to whitespace in row + 1 in in

Re: [R] Regular Expressions + Matrices

2012-08-10 Thread Fred G
LSE) > > index<-grep("New York.*",dat1$NAME) > dat1[index,] > # ID NAME YEAR SOURCE > #1 1 New York Mets 1900ESPN > #2 2 New York Yankees 1920 Cooperstown > > A.K. > > > > - Original Message - > From: Fred G

Re: [R] Regular Expressions + Matrices

2012-08-10 Thread Fred G
My code doesn't predict a point you've made clear in this post. Inline. > Em 10-08-2012 19:05, Fred G escreveu: > > Thanks Arun. The only issue is that I need the code to be very >> generalizable, such that the grep() really has to be if the first string >> up >>

Re: [R] Regular Expressions + Matrices

2012-08-10 Thread Fred G
6 Chicago Blacksox 1701 made up > 7 7 Chicago Cubs 1702 made up > 8 8 Chicago Whitesox 1703 made up > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > > > -Original Message- > > From: r-help-boun...@r-project.

[R] rbind()

2012-01-20 Thread Fred G
Hello there, Much thanks in advance for any help. I have a few questions: 1) Why do I keep getting the following error: File1 <- read.csv("../RawData/File1.csv",as.is=TRUE,row.names=1) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : c

[R] regular expression

2012-02-29 Thread Fred G
Computer Friends, with the following example lines: [107] "98-610: Cell type: S; Surv(months): 6; STATUS(0=alive, 1=dead): 1" [108] "99-625: Cell type: S; Surv(months): 21; STATUS(0=alive, 1=dead): 1" i want to be able to isolate the number of months of survival for each row. is there a regula