Re: [R] remove a row

2019-11-28 Thread Bert Gunter
Of course! Use regexec() and regmatches() > regmatches(dat$varx,regexec("(^[[:digit:]]{1,3})([[:alpha:]]{1,2})([[:digit:]]{1,5}$)",dat$varx)) [[1]] [1] "9F209" "9" "F" "209" [[2]] character(0) [[3]] [1] "2F250" "2" "F" "250" [[4]] character(0) [[5]] character(0) [[6]] characte

Re: [R] remove a row

2019-11-28 Thread Ashta
Thank you so much Bert. Is it possible to split the varx into three ( area code, region and the numeric part)as a separate variable On Thu, Nov 28, 2019 at 7:31 PM Bert Gunter wrote: > > Use regular expressions. > > See ?regexp and ?grep > > Using your example: > > > grep("^[[:digit:]]{1,3}[[:

Re: [R] remove a row

2019-11-28 Thread Bert Gunter
Use regular expressions. See ?regexp and ?grep Using your example: > grep("^[[:digit:]]{1,3}[[:alpha:]]{1,2}[[:digit:]]{1,5}$",dat$varx,value = TRUE) [1] "9F209" "2F250" "121FL50" Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking

[R] remove a row

2019-11-28 Thread Ashta
Hi all, I want to remove a row based on a condition in one of the variables from a data frame. When we split this string it should be composed of 3-2- 5 format (3 digits numeric, 2 characters and 5 digits numeric). Like area code -region-numeric. The max length of the area code should be 3, the

Re: [R] Remove a row containing a specific value for a column

2013-04-07 Thread arun
p Cc: Sent: Sunday, April 7, 2013 2:31 PM Subject: [R] Remove a row containing a specific value for a column Dear all, Could anyone help me with the following? DATA <- data.frame(rbind(c("Red1", 1, 1, 1), c("Blue1", 1, 1, 1), c("Red2", 1, 1, 1), c("Red3"

[R] Remove a row containing a specific value for a column

2013-04-07 Thread Beatriz González Domínguez
Dear all, Could anyone help me with the following? DATA <- data.frame(rbind(c("Red1", 1, 1, 1), c("Blue1", 1, 1, 1), c("Red2", 1, 1, 1), c("Red3", 1, 1, 1))) colnames(DATA) <- c("A", "B","C", "D") #Option 1 DATA <- DATA[-2, ] #Same result I would like to achieve with Option 2 #Option 2 - I wou

Re: [R] remove a row from a dataframe, row names disappear - solution

2010-02-05 Thread Euan Reavie
Thank you Sarah.I'm glad it was a quick fix: On Fri, Feb 5, 2010 at 8:50 AM, Sarah Goslee <> wrote: > You're not only removing a row of data, you are invoking the default > behavior of subset, which is to collapse the subsetted result to the > smallest possible type, which in this case is a vecto

Re: [R] remove a row from a dataframe, row names disappear

2010-02-05 Thread Sarah Goslee
You're not only removing a row of data, you are invoking the default behavior of subset, which is to collapse the subsetted result to the smallest possible type, which in this case is a vector. Vectors have no rows, and thus no row names. You need the drop=FALSE argument, as in ENV <- ENV[-1, , dr

[R] remove a row from a dataframe, row names disappear

2010-02-05 Thread Euan Reavie
I find this odd because it doesn't appear to happen in larger datasets. I have the following data set ENV with the first column set as row.names: > ENV TPlog 001S29H 0.601 002S42H 0.602 003S43S 0.779 004S43S 0.702 005S51H 0.978 006S52P 2.718 If I apply > ENV <- ENV[-1,] # remove f