Re: [R] Removing polygons from shapefile of Scotland and Islands

2024-05-14 Thread Jan van der Laan
I believe mapshaper has functionality for removing small 'islands'. There is a webinterface for mapshaper, but I see there is also an R-package (see https://search.r-project.org/CRAN/refmans/rmapshaper/html/ms_filter_islands.html for island removal). If you want to manually select which islan

[R] Removing polygons from shapefile of Scotland and Islands

2024-05-14 Thread Nick Wray
Hello I have a shapefile of Scotland, including the islands. The river flow data I am using is only for the mainland and for a clearer and larger map I would like to not plot Orkney and Shetland to the north of the mainland, as I don't need them. The map I have I got from https://borders.ukdatas

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread avi.e.gross
, February 12, 2023 5:19 PM To: Andrew Simmons Cc: R-help Mailing List Subject: Re: [R] Removing variables from data frame with a wile card In the line suggested by Andrew Simmons, mydata <- mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] what does drop=FALSE do? Thanks. On 1/14

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Steven Yen
Great, Thanks. Now I have many options. Steven from iPhone > On Feb 13, 2023, at 10:52 AM, Andrew Simmons wrote: > > What I meant is that that > > mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] > > and > > mydata[!grepl("^yr", colnames(mydata))] > > should be identical. Some peopl

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Andrew Simmons
What I meant is that that mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] and mydata[!grepl("^yr", colnames(mydata))] should be identical. Some people would prefer the first because the indexing looks the same as matrix indexing, whereas some people would prefer the second because it is

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Jeff Newmiller
Complain, complain... x[ names( x ) != "V2" ] or x[ ! names( x ) %in% c( "V2", "V3" ) ] or any other character or logical or integer expression that selects columns you want... On February 12, 2023 6:38:00 PM PST, Steven Yen wrote: >x[“V2”] would retain columns of x headed by V2. What I need

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Steven Yen
x[“V2”] would retain columns of x headed by V2. What I need is the opposite——I need a data grime with those columns excluded. Steven from iPhone > On Feb 13, 2023, at 9:33 AM, Rolf Turner wrote: > >  >> On Sun, 12 Feb 2023 14:57:36 -0800 >> Jeff Newmiller wrote: >> >> x["V2"] >> >> is more

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Rolf Turner
On Sun, 12 Feb 2023 14:57:36 -0800 Jeff Newmiller wrote: > x["V2"] > > is more efficient than using drop=FALSE, and perfectly normal syntax > (data frames are lists of columns). I never cease to be amazed by the sagacity and perspicacity of the designers of R. I would have worried that x[

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Steven T. Yen
Thanks Jeff and Andrew. My initial file, mydata, is a data frame with 92 columns (variables). After the operation (trimming), it remains a data frame with 72 variables. So yes indeed, I do not need the drop=FALSE. > is.data.frame(mydata) [1] TRUE > ncol(mydata) [1] 92 > mydata<-mydata[,!grepl("

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Jeff Newmiller
x["V2"] is more efficient than using drop=FALSE, and perfectly normal syntax (data frames are lists of columns). I would ignore the naysayers, or put a comment in if you want to accelerate their uptake. As I understand it, one of the main reasons tibbles exist is because of drop=TRUE. List-sl

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Andrew Simmons
drop = FALSE means that should the indexing select exactly one column, then return a data frame with one column, instead of the object in the column. It's usually not necessary, but I've messed up some data before by assuming the indexing always returns a data frame when it doesn't, so drop = FALSE

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Steven T. Yen
In the line suggested by Andrew Simmons, mydata <- mydata[, !grepl("^yr", colnames(mydata)), drop = FALSE] what does drop=FALSE do? Thanks. On 1/14/2023 8:48 PM, Steven Yen wrote: > Thanks to all. Very helpful. > > Steven from iPhone > >> On Jan 14, 2023, at 3:08 PM, Andrew Simmons wrote: >> >>

Re: [R] Removing variables from data frame with a wile card

2023-01-15 Thread Rui Barradas
From: R-help on behalf of Valentin Petzel Sent: Saturday, January 14, 2023 1:21 PM To: avi.e.gr...@gmail.com Cc: 'R-help Mailing List' Subject: Re: [R] Removing variables from data frame with a wile card Hello Avi, while something like d$something <- ..

Re: [R] Removing variables from data frame with a wile card

2023-01-15 Thread avi.e.gross
, John Sent: Sunday, January 15, 2023 11:55 AM To: Valentin Petzel ; avi.e.gr...@gmail.com Cc: 'R-help Mailing List' Subject: Re: [R] Removing variables from data frame with a wile card I am new to this thread. At the risk of presenting something that has been shown before, below I d

Re: [R] Removing variables from data frame with a wile card

2023-01-15 Thread Sorkin, John
lp on behalf of Valentin Petzel Sent: Saturday, January 14, 2023 1:21 PM To: avi.e.gr...@gmail.com Cc: 'R-help Mailing List' Subject: Re: [R] Removing variables from data frame with a wile card Hello Avi, while something like d$something <- ... may seem like you're directly modify

Re: [R] Removing variables from data frame with a wile card

2023-01-15 Thread Valentin Petzel
l things change. > > For those who like to use the tidyverse, it comes with lots of tools that let > you select columns that start with or end with or contain some pattern and I > find that way easier. > > > > -Original Message- > From: R-help On Behalf Of Steve

Re: [R] Removing variables from data frame with a wile card

2023-01-14 Thread avi.e.gross
do not want, simply melt away. The part about selecting or deselecting columns can often be used in many of the verbs. From: John Kane Sent: Saturday, January 14, 2023 4:07 PM To: avi.e.gr...@gmail.com Cc: R-help Mailing List Subject: Re: [R] Removing variables from data frame with a wile

Re: [R] Removing variables from data frame with a wile card

2023-01-14 Thread avi.e.gross
I prefer to avoid religious wars. -Original Message- From: Valentin Petzel Sent: Saturday, January 14, 2023 1:21 PM To: avi.e.gr...@gmail.com Cc: 'R-help Mailing List' Subject: Re: [R] Removing variables from data frame with a wile card Hello Avi, while something like d$something <- ...

Re: [R] Removing variables from data frame with a wile card

2023-01-14 Thread John Kane
ier. > > > > -Original Message- > From: R-help On Behalf Of Steven Yen > Sent: Saturday, January 14, 2023 7:49 AM > To: Andrew Simmons > Cc: R-help Mailing List > Subject: Re: [R] Removing variables from data frame with a wile card > > Thanks to all. Ver

Re: [R] Removing variables from data frame with a wile card

2023-01-14 Thread avi.e.gross
find that way easier. -Original Message- From: R-help On Behalf Of Steven Yen Sent: Saturday, January 14, 2023 7:49 AM To: Andrew Simmons Cc: R-help Mailing List Subject: Re: [R] Removing variables from data frame with a wile card Thanks to all. Very helpful. Steven from iPhone >

Re: [R] Removing variables from data frame with a wile card

2023-01-14 Thread Bill Dunlap
The -grep(pattern,colnames) as a subscript is a bit dangerous. If no colname matches the pattern then all columns will be omitted (because -0 is the same as 0, which means no column). !grepl(pattern,colnames) avoids this problem. > mydata <- data.frame(A=1:3,B=11:13) > mydata[, -grep("^yr", colna

Re: [R] Removing variables from data frame with a wile card

2023-01-14 Thread Steven Yen
Thanks to all. Very helpful. Steven from iPhone > On Jan 14, 2023, at 3:08 PM, Andrew Simmons wrote: > > You'll want to use grep() or grepl(). By default, grep() uses extended > regular expressions to find matches, but you can also use perl regular > expressions and globbing (after converting

Re: [R] Removing variables from data frame with a wile card

2023-01-13 Thread Andrew Simmons
You'll want to use grep() or grepl(). By default, grep() uses extended regular expressions to find matches, but you can also use perl regular expressions and globbing (after converting to a regular expression). For example: grepl("^yr", colnames(mydata)) will tell you which 'colnames' start with

Re: [R] Removing variables from data frame with a wile card

2023-01-13 Thread Eric Berger
mydata[, -grep("^yr",colnames(mydata))] On Sat, Jan 14, 2023 at 8:57 AM Steven T. Yen wrote: > I have a data frame containing variables "yr3",...,"yr28". > > How do I remove them with a wild cardsomething similar to "del yr*" > in Windows/doc? Thank you. > > > colnames(mydata) >[1] "yea

[R] Removing variables from data frame with a wile card

2023-01-13 Thread Steven T. Yen
I have a data frame containing variables "yr3",...,"yr28". How do I remove them with a wild cardsomething similar to "del yr*" in Windows/doc? Thank you. > colnames(mydata)   [1] "year"   "weight" "confeduc"   "confothr" "college"   [6] ...  [41] "yr3"    "yr4"    "yr5"

Re: [R] removing non-table lines

2022-09-19 Thread Eric Berger
ample in read.csv() or > comment="string" in the tidyverse function read_csv(). > > And, of course you can skip lines if that makes sense albeit it can be tricky > with header lines. > > -Original Message- > From: R-help On Behalf Of Rui Barradas > Sent: S

Re: [R] removing non-table lines

2022-09-18 Thread avi.e.gross
on read_csv(). And, of course you can skip lines if that makes sense albeit it can be tricky with header lines. -Original Message- From: R-help On Behalf Of Rui Barradas Sent: Sunday, September 18, 2022 6:19 PM To: Nick Wray ; r-help@r-project.org Subject: Re: [R] removing non-table line

Re: [R] removing non-table lines

2022-09-18 Thread Rui Barradas
Helo, Unfortunatelly there are many files with a non tabular data section followed by the data. R's read.table has a skip argument: skip integer: the number of lines of the data file to skip before beginning to read data. If you do not know how many lines to skip because it's not always

Re: [R] removing non-table lines

2022-09-18 Thread Jeff Newmiller
Use the skip parameter if the number of header lines is always the same. On September 18, 2022 12:39:50 PM PDT, Nick Wray wrote: >Hello - I am having to download lots of rainfall and temperature data in >csv form from the UK Met Office. The data isn't a problem - it's in nice >columns and can be

Re: [R] removing non-table lines

2022-09-18 Thread CALUM POLWART
Can you provide a sample of say the first 3 rows then the last 2 rows before the CSV starts. Are there always the same number of lines at the top? Or can it vary depending what non-sense the Met Office decided to contaminate it with? This should be solvable with some sample data. Base R or Tidyv

[R] removing non-table lines

2022-09-18 Thread Nick Wray
Hello - I am having to download lots of rainfall and temperature data in csv form from the UK Met Office. The data isn't a problem - it's in nice columns and can be read into R easily - the problem is that in each csv there are 60 or so lines of information first which are not part of the columnar

Re: [R] removing dates from xts object..

2022-07-25 Thread akshay kulkarni
Dear Joshua, Thanks a lot... Yours sincrely, AKSHAY M KULKARNI From: Joshua Ulrich Sent: Tuesday, July 26, 2022 2:20 AM To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] removing dates from xts object.. On Mon, Jul 25, 2022 at 3

Re: [R] removing dates from xts object..

2022-07-25 Thread akshay kulkarni
ich Sent: Tuesday, July 26, 2022 1:56 AM To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] removing dates from xts object.. This is the most straightforward and general way I can think of quickly: library(xts) data(sample_matrix) x <- as.xts(sample_matrix, dateFormat = "Da

[R] removing dates from xts object..

2022-07-25 Thread akshay kulkarni
Dear members, I have: > head(testOHLC) HINDUNILVR.NS.Open HINDUNILVR.NS.High HINDUNILVR.NS.Low HINDUNILVR.NS.Close 2007-01-02 217.80 219.00215.45 216.40 2007-01-03 217.00 217.65

Re: [R] Removing a space from a string

2020-07-29 Thread Dennis Fisher
Richard Per your requests: 1. Plain text: no spaces 2. read_docx: spaces 3. read_rtf: no spaces 4. Not requested by you: copying from the Word document, then pasting into “vim”: no spaces The Word document was created by hand but #1, #3, and #4 confirm that i

Re: [R] Removing a space from a string

2020-07-29 Thread Kimmo Elo
Hi! How about this? --- snip --- > x <- c("STRING 01. Remainder of the string","STR ING 01. Remainder of the string","STRIN G 01. Remainder of the string","STR IN G 01. Remainder of the string") > x1<-unlist(strsplit(x,"\\.")) > for (i in seq(1,length(x1),2)) { x[(i+1) %/% 2]<-paste(gsub(

Re: [R] Removing a space from a string

2020-07-28 Thread Richard O'Keefe
The spaces may not have been VISIBLE in the Word document, but that does not mean that there wasn't anything THERE. - What happens if you open the document in Word and save it as plain text? - What happens if you open the document in Word and save it as RTF, then read that using read_rtf? - If

Re: [R] Removing a space from a string

2020-07-28 Thread Dennis Fisher
Richard In reply to your “first response”, the text was originally in a Word document and it did NOT contain the errant spaces. I used read_docx in the textreadr package to access the text. The spaces were added during that step. I am copying the maintainer of that package to see if he has a

Re: [R] Removing a space from a string

2020-07-28 Thread Richard O'Keefe
The first response has to be "how did the spaces get there in the first place?" Can you fix the process that creates the data? If the process sometimes generates one extra space, are you sure it never generates two? But let's treat this purely as a regular expression problem, where if there is a

Re: [R] Removing a space from a string

2020-07-28 Thread Bert Gunter
Note that my previous strategy can be expressed slightly more clearly as: x <- c("STRING 01. Remainder of the string", "STR ING 01. Remainder of the string", "STRIN G 01. Remainder of the string", "STR IN G 01. Remainder of the string") ## more spaces in this last example entry rx <- "([^[:d

Re: [R] Removing a space from a string

2020-07-28 Thread Bert Gunter
1. Thanks for the nice reprex. 2. However, I thought there was still a bit of ambiguity. I interpreted your specification to mean: "any number of spaces could occur in the beginning alphabetic part of the strings before one or more digits occur followed by a '.' (a period) and then more stuff after

Re: [R] Removing a space from a string

2020-07-28 Thread Rasmus Liland
On 2020-07-28 23:00 +0200, Rasmus Liland wrote: | | Perhaps by using gregexpr to look for | dots, remove spaces from the substring until the first | finding, then pasting it back. | | strings <- | c("STRING 01. Remainder of the string.", | "STR ING 01. Remainder of the st

Re: [R] Removing a space from a string

2020-07-28 Thread cpolwart
This RegEx would do it I think: \s(?=.*\s\d*\.) Looks for space - \s Before any strings followed by space, numbers, period text <- "STR ING 01. Remainder of the string" stringr::str_replace_all(text, "\\s(?=.*\\s\\d*\\.)", "") Should do it I think! On 2020-07-28 21:34, Dennis Fisher wrote:

Re: [R] Removing a space from a string

2020-07-28 Thread Rasmus Liland
Dear Dennis, On 2020-07-28 13:20 -0700, Dennis Fisher wrote: | Colleagues | | I have strings that contain a space in | an unexpected location. The intended | string is: | “STRING 01. Remainder of the string" | However, variants are: | “STR ING 01. Remainder of the string" |

Re: [R] Removing a space from a string

2020-07-28 Thread Dennis Fisher
Only the spaces in STRING. However, if I inadvertently delete the space between STRING and NN, I can add it back in. Dennis Fisher MD P < (The "P Less Than" Company) Phone / Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com > On Jul 28, 2020, at 1:29 PM, cpo

Re: [R] Removing a space from a string

2020-07-28 Thread Dennis Fisher
It is possible that there will be > 1 space. But, most likely only one (i.e., a solution for one space will suffice; a solution for > 1 space would be even better) Dennis Fisher MD P < (The "P Less Than" Company) Phone / Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com

Re: [R] Removing a space from a string

2020-07-28 Thread cpolwart
On 2020-07-28 21:31, Dennis Fisher wrote: Only the spaces in STRING. However, if I inadvertently delete the space between STRING and NN, I can add it back in. Can there only be one space in STR ING or is ST RI NG possible? Dennis Fisher MD P < (The "P Less Than" Company) Phone / Fax: 1-866

Re: [R] Removing a space from a string

2020-07-28 Thread cpolwart
On 2020-07-28 21:20, Dennis Fisher wrote: R 4.0.2 OS X Colleagues I have strings that contain a space in an unexpected location. The intended string is: “STRING 01. Remainder of the string" However, variants are: “STR ING 01. Remainder of the string" “STRIN G 01. Rem

[R] Removing a space from a string

2020-07-28 Thread Dennis Fisher
R 4.0.2 OS X Colleagues I have strings that contain a space in an unexpected location. The intended string is: “STRING 01. Remainder of the string" However, variants are: “STR ING 01. Remainder of the string" “STRIN G 01. Remainder of the string" I would like a gener

Re: [R] removing part of a string

2018-05-21 Thread Rui Barradas
Hello, Ulrik's way is simpler therefore better. I would use it, not mine. As for an explanation of mine, here it goes. 1) Parenthesis are meta-characters and must be escaped if you want to match them: \\( and \\) 2) You want to keep them so I used groups, i.e., put what you want between

Re: [R] removing part of a string

2018-05-21 Thread Ulrik Stervbo
I would use sub("\\(.*\\)", "()", s) It is essentially the same as Rui's suggestion, but I find the purpose to be more clear. It might also be a little more efficient. HTH Ulrik On Mon, 21 May 2018, 15:38 Rui Barradas, wrote: > Hello, > > Try this. > > > ss1 <- "z:f(5, a=3, b=4, c='1:4', d=2)

Re: [R] removing part of a string

2018-05-21 Thread Rui Barradas
Hello, Try this. ss1 <- "z:f(5, a=3, b=4, c='1:4', d=2)" ss2 <- "f(5, a=3, b=4, c=\"1:4\", d=2)*z" fun <- function(s) sub("(\\().*(\\))", "\\1\\2", s) fun(ss1) #[1] "z:f()" fun(ss2) #[1] "f()*z" Hope this helps, Rui Barradas On 5/21/2018 2:33 PM, Vito M. R. Muggeo wrote: dear all, I am

[R] removing part of a string

2018-05-21 Thread Vito M. R. Muggeo
dear all, I am stuck on the following problem. Give a string like ss1<- "z:f(5, a=3, b=4, c='1:4', d=2)" or ss2<- "f(5, a=3, b=4, c=\"1:4\", d=2)*z" I would like to remove all entries within parentheses.. Namely, I aim to obtain respectively "z:f()" or "f()*z" I played with sub() and gsub(

Re: [R] Removing columns from big.matrix which have only one value

2018-04-23 Thread PIKAL Petr
help-boun...@r-project.org] On Behalf Of Jack Arnestad > Sent: Saturday, April 21, 2018 9:17 PM > To: r-help@r-project.org > Subject: [R] Removing columns from big.matrix which have only one value > > I have a very large binary matrix, stored as a big.matrix to conserve memory > (

Re: [R] Removing columns from big.matrix which have only one value

2018-04-21 Thread Bert Gunter
Maybe base R's unique() function might be useful? It uses hashing I believe. Bert On Sat, Apr 21, 2018, 12:17 PM Jack Arnestad wrote: > I have a very large binary matrix, stored as a big.matrix to conserve > memory (it is over 2 gb otherwise - 5 million columns and 100 rows). > > r <- 100 > c

[R] Removing columns from big.matrix which have only one value

2018-04-21 Thread Jack Arnestad
I have a very large binary matrix, stored as a big.matrix to conserve memory (it is over 2 gb otherwise - 5 million columns and 100 rows). r <- 100 c <- 1 m4 <- matrix(sample(0:1,r*c, replace=TRUE),r,c) m4 <- cbind(m4, 1) m4 <- as.big.matrix(m4) I need to remove every column which has only on

Re: [R] Removing a data subset

2017-11-30 Thread David Doyle
Thank Rainer and Jim!! The end result was: #Makes a new data set name "MyData_Minus_MW01" that contains all the data where the Location Column is not equal to MW01 and the comma after that ensures that all columns are copied into the amended data.frame. MyData_Minus_MW01 <- MyData[ MyData$Location

Re: [R] Removing a data subset

2017-11-29 Thread Ivan Calandra
Hi David, You "just" need to learn how to subset your data.frame, see functions like ?subset and ?"[", as well as a good guide to understand the subtleties! Some graphic functions also have a built-in argument to subset within the function (e.g. argument 'subset' in 'plot.formula'), although

Re: [R] Removing a data subset

2017-11-29 Thread Rainer Schuermann
Reading in the data from the file x <- read.csv( "ExampleData.csv", header = TRUE, stringsAsFactors = FALSE ) Subsetting as you want x <- x[ x$Location != "MW01", ] This selects all rows where the value in column 'Location' is not equal to "MW01". The comma after that ensures that all

[R] Removing a data subset

2017-11-29 Thread David Doyle
Say I have a dataset that looks like LocationYear GW_Elv MW011999 546.63 MW021999 474.21 MW031999 471.94 MW041999466.80 MW012000545.90 MW022000546.10 The whole dataset is at http://doylesdartden.com

Re: [R] removing dropouts from survival analysis

2017-01-23 Thread Bert Gunter
Sorry. You may get private replies, but this *is* way OT on this list. Try stats.stackexchange.com instead for statistical queries. Or, better yet, find local consulting help. Non-random dropouts are a difficult issue. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people

[R] removing dropouts from survival analysis

2017-01-23 Thread Damjan Krstajic
Dear All. Apologies for posting a question regarding survival analysis, and not R, to the R-help list. In the past I received the best advices from the R community. The random censorship model (the censoring times independent of the failure times and vice versa) is one of the fundamental assu

Re: [R] removing all non-numeric characters from a string, but not "."

2016-07-26 Thread Dimitri Liakhovitski
Thank you very much, gentlemen! On Tue, Jul 26, 2016 at 5:48 PM, peter dalgaard wrote: > >> On 26 Jul 2016, at 23:28 , Dimitri Liakhovitski >> wrote: >> >> Hello! >> >> I have a string x: >> x <- c("x - 84", "y - 293.04", "z = 12.5") >> >> I want to remove all the non-numeric stuff from it. The

Re: [R] removing all non-numeric characters from a string, but not "."

2016-07-26 Thread peter dalgaard
> On 26 Jul 2016, at 23:28 , Dimitri Liakhovitski > wrote: > > Hello! > > I have a string x: > x <- c("x - 84", "y - 293.04", "z = 12.5") > > I want to remove all the non-numeric stuff from it. The following works: > gsub("[^0-9]", "", x) > > However, it strips my numbers of "." > > Help -

Re: [R] removing all non-numeric characters from a string, but not "."

2016-07-26 Thread Marc Schwartz
> On Jul 26, 2016, at 4:39 PM, Marc Schwartz wrote: > > >> On Jul 26, 2016, at 4:28 PM, Dimitri Liakhovitski >> wrote: >> >> Hello! >> >> I have a string x: >> x <- c("x - 84", "y - 293.04", "z = 12.5") >> >> I want to remove all the non-numeric stuff from it. The following works: >> gsub(

Re: [R] removing all non-numeric characters from a string, but not "."

2016-07-26 Thread David Winsemius
> On Jul 26, 2016, at 2:28 PM, Dimitri Liakhovitski > wrote: > > gsub("[^0-9]", "", x) ?regex I think you might be bit embarrassed because it seems pretty obvious once you know that character class elements like "." don't need to be escaped so it's just this: > gsub("[^0-9.]", "", x) [1]

Re: [R] removing all non-numeric characters from a string, but not "."

2016-07-26 Thread Marc Schwartz
> On Jul 26, 2016, at 4:28 PM, Dimitri Liakhovitski > wrote: > > Hello! > > I have a string x: > x <- c("x - 84", "y - 293.04", "z = 12.5") > > I want to remove all the non-numeric stuff from it. The following works: > gsub("[^0-9]", "", x) > > However, it strips my numbers of "." > > Help

[R] removing all non-numeric characters from a string, but not "."

2016-07-26 Thread Dimitri Liakhovitski
Hello! I have a string x: x <- c("x - 84", "y - 293.04", "z = 12.5") I want to remove all the non-numeric stuff from it. The following works: gsub("[^0-9]", "", x) However, it strips my numbers of "." Help - how could I do the same but leave the "." in? Thanks a lot! -- Dimitri Liakhovitski

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-05-02 Thread Martin Maechler
> Bert Gunter > on Mon, 2 May 2016 06:20:52 -0700 writes: > Martin et. al.: > na.omit(frame) will remove all rows/cases in which an NA occurs. I'm > not sure that this is what the OP wanted, which seemed to be to > separately remove NA's from each column and plot the

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-05-02 Thread Bert Gunter
Martin et. al.: na.omit(frame) will remove all rows/cases in which an NA occurs. I'm not sure that this is what the OP wanted, which seemed to be to separately remove NA's from each column and plot the resulting column. This is what the lapply (and the OP's provided code) does, anyway. Also, lap

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-05-02 Thread Martin Maechler
> Mike Smith > on Sun, 1 May 2016 08:15:44 +0100 writes: On Apr 30, 2016, at 12:58 PM, Mike Smith wrote: Hi First post and a relative R newbie I am using the vioplot library to produce some violin plots. DW> It's a package,

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-05-01 Thread David Winsemius
> On May 1, 2016, at 12:15 AM, Mike Smith wrote: > On Apr 30, 2016, at 12:58 PM, Mike Smith wrote: > Hi > First post and a relative R newbie > I am using the vioplot library to produce some violin plots. > > DW> It's a package, not a library. > I have an

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-05-01 Thread Mike Smith
>>> On Apr 30, 2016, at 12:58 PM, Mike Smith wrote: >>> Hi >>> First post and a relative R newbie >>> I am using the vioplot library to produce some violin plots. DW> It's a package, not a library. >>> I have an input CSV with columns off irregular length that contain NAs. I >>> wa

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-04-30 Thread Jeff Newmiller
But require() should not be used interchangeably with library()... the return value from require() should always be tested. -- Sent from my phone. Please excuse my brevity. On May 1, 2016 3:03:59 AM GMT+01:00, Tom Wright wrote: >Never let it be said there's only one way to do a thing: > >requi

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-04-30 Thread Tom Wright
Never let it be said there's only one way to do a thing: require(ggplot2) require(dplyr) #create a sample dataset dat <- data.frame(y1=sample(c(1:10,NA),20,replace=TRUE), y2=sample(c(1:10,NA),20,replace=TRUE), y3=sample(c(1:10,NA),20,replace=TRU

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-04-30 Thread David Winsemius
> On Apr 30, 2016, at 4:16 PM, David Winsemius wrote: > > >> On Apr 30, 2016, at 12:58 PM, Mike Smith wrote: >> >> Hi >> >> First post and a relative R newbie >> >> I am using the vioplot library to produce some violin plots. It's a package, not a library. >> I have an input CSV

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-04-30 Thread David Winsemius
> On Apr 30, 2016, at 12:58 PM, Mike Smith wrote: > > Hi > > First post and a relative R newbie > > I am using the vioplot library to produce some violin plots. I have an input > CSV with columns off irregular length that contain NAs. I want to strip the > NAs out and produce a multiple

[R] Removing NAs from dataframe (for use in Vioplot)

2016-04-30 Thread Mike Smith
Hi First post and a relative R newbie I am using the vioplot library to produce some violin plots. I have an input CSV with columns off irregular length that contain NAs. I want to strip the NAs out and produce a multiple violin plot automatically labelled using the headers. At the moment

Re: [R] removing factor values in the main data frame

2016-03-01 Thread peter dalgaard
> On 01 Mar 2016, at 18:33 , David L Carlson wrote: > > You need to learn how to send emails in plain text since html gets mangled on > r-help. See your message below. If I understand your question, it has to do > with what happens to factor levels when you subset your data. Subsetting a > fa

Re: [R] removing factor values in the main data frame

2016-03-01 Thread Ulrik Stervbo
Without more information it is hard to see where things go wrong. To judge from your text, I am not sure you do things correct. You are doing it along the lines of: str(mydata) submydata <- subset(mydata, ... ) submydata <- droplevels(submydata) str(submydata) right? On Tue, 1 Mar 2016 at 17:45

Re: [R] removing factor values in the main data frame

2016-03-01 Thread Ulrik Stervbo
Hi, I think droplevels(df) is what you are looking for. Best wishes, Ulrik On Tue, 1 Mar 2016 at 17:33 hoda rahmati via R-help wrote: > Hi all,I have the following main data frame:(mydata)$ TE : num 40 > 40 20 20 20 20 20 20 20 40 ...$ TR : num 49 49 28 28 28 28 28 28 28 > 49 .

Re: [R] removing factor values in the main data frame

2016-03-01 Thread hoda rahmati via R-help
I also tried droplevels but after getting str(submydata) again I see no changes in COUNTRY  On Tuesday, March 1, 2016 8:38 AM, Ulrik Stervbo wrote: Hi, I think droplevels(df) is what you are looking for. Best wishes, Ulrik On Tue, 1 Mar 2016 at 17:33 hoda rahmati via R-help wrote:

[R] removing factor values in the main data frame

2016-03-01 Thread hoda rahmati via R-help
Hi all,I have the following main data frame:(mydata)        $ TE : num 40 40 20 20 20 20 20 20 20 40 ...        $ TR : num 49 49 28 28 28 28 28 28 28 49 ...        $ COUNTRY : Factor w/ 27 levels "","AU","BA","BE",..: 8 8 8 8 8 ...among the COUNTRY I just need US and AU,first I get a subset to c

Re: [R] removing data based on date pairs in a separate data frame

2016-02-29 Thread William Dunlap via R-help
If your start/end pairs are not overlapping you can use findInterval() to do this pretty quickly. E.g., isInABound <- function (x, low, high) { stopifnot(length(low) == length(high)) bounds <- rep(low, each = 2) bounds[seq(2, length(bounds), by = 2)] <- high stopifnot(!is.unsorted(

Re: [R] removing data based on date pairs in a separate data frame

2016-02-29 Thread Bert Gunter
What is the format of your date columns? -- character, factor, POSIXxx,... ?? See ?str to find out. (Reply to the list, not just me; others are far more facile at dates than I am). Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking th

[R] removing data based on date pairs in a separate data frame

2016-02-29 Thread Thomas Barningham
Dear R users, I have two data frames. The first contains a date/time column and the concentration of a species: head(mydata) datespecies 1 2016-01-31 23:59:53 -559.17 2 2016-02-01 00:00:53 -556.68 3 2016-

Re: [R] Removing a dollar sign from a character vector

2016-02-11 Thread William Dunlap via R-help
I should have said that R-3.2.3 requires the $ to be backslashed even when it is not at the end of the pattern: > gsub("$[[:digit:]]*", "", c("$VAR", "$20/oz.")) [1] "$VAR""$20/oz." > gsub("\\$[[:digit:]]*", "", c("$VAR", "$20/oz.")) [1] "VAR" "/oz." Modern Linuxen's tools like sed d

Re: [R] Removing a dollar sign from a character vector

2016-02-11 Thread William Dunlap via R-help
In certain programs (not current R), a pattern with stuff after a naked dollar sign would not match anything because dollar meant end-of-string. In any case I prefer simple rules like 'backslash a dollar sign' instead of 'backslash a dollar sign at the end of the pattern but not elsewhere'. Bill

Re: [R] Removing a dollar sign from a character vector

2016-02-11 Thread Jeff Newmiller
The "end of string" special meaning only applies when the dollar sign is at the right end of the string (as it was in the OP attempt). That is, it is NOT generally necessary to wrap it in brackets to remove the special meaning unless it would otherwise be at the end of the pattern string. --

Re: [R] Removing a dollar sign from a character vector

2016-02-10 Thread William Dunlap via R-help
> y [1] "$1,000.00 " "$1,000.00 " "$1,000.00 " "$2,600.00 " "$2,600.00 " > gsub("$", "", y) [1] "$1,000.00 " "$1,000.00 " "$1,000.00 " "$2,600.00 " "$2,600.00 “ # no change. Why? "$" as a regular expression means "end of string", which has zero length - replacing "end of string" with n

Re: [R] Removing a dollar sign from a character vector

2016-02-10 Thread Jeff Newmiller
y <- as.numeric( gsub( "[$, ]", "", y ) ) -- Sent from my phone. Please excuse my brevity. On February 10, 2016 9:39:16 PM PST, James Plante wrote: >What I’ve got: ># sessionInfo() >R version 3.2.3 (2015-12-10) >Platform: x86_64-apple-darwin13.4.0 (64-bit) >Running under: OS X 10.11.3 (El Capita

[R] Removing a dollar sign from a character vector

2016-02-10 Thread James Plante
What I’ve got: # sessionInfo() R version 3.2.3 (2015-12-10) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.11.3 (El Capitan) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets

Re: [R] removing outlier --> use robust regression !

2015-09-15 Thread Martin Maechler
> Juli > on Sat, 12 Sep 2015 02:32:39 -0700 writes: > Hi Jim, thank you for your help. :) > My point is, that there are outlier and I don´t really > know how to deal with that. > I need the dataframe for a regression and read often that > only a few outlier

Re: [R] removing outlier

2015-09-13 Thread David Winsemius
If this mailing list accepted formatted submissions I would have used the trèsModernSarcastic font for my first sentence. Failing the availability of that mode of communication I am (top) posting through Nabble (perhaps) in "Comic Sans". On Sat, Sep 12, 2015 at 9:52 AM, David Winsemius

Re: [R] removing outlier

2015-09-13 Thread Bert Gunter
... and this, of course, is a nice example of how statistics contributes to the "irreproducibility crisis" now roiling Science. Cheers, Bert (Quote from a long ago engineering colleague: "Whenever I see an outlier, I never know whether to throw it away or patent it.") Bert Gunter "Data is not

Re: [R] removing outlier

2015-09-12 Thread David Winsemius
On Sep 12, 2015, at 2:32 AM, Juli wrote: > Hi Jim, > > thank you for your help. :) > > My point is, that there are outlier and I don´t really know how to deal with > that. > > I need the dataframe for a regression and read often that only a few outlier > can change your results very much. In

Re: [R] removing outlier

2015-09-12 Thread Juli
Hi Jim, thank you for your help. :) My point is, that there are outlier and I don´t really know how to deal with that. I need the dataframe for a regression and read often that only a few outlier can change your results very much. In addition, regression diacnostics didn´t indcate me the best

Re: [R] removing outlier

2015-09-11 Thread Jim Lemon
Hi Juli, What you can do is to make your outlier remover into a function like this: remove_outlier_by_sd<-function(x,nsd=3) { meanx<-mean(x,na.rm=TRUE) sdx<-sd(x,na.rm=TRUE) return(x[abs(x-xmean) < nsd*sdx]) } Then apply the function to your data frame ("table") newDA<-sapply(DA,remove_outlie

[R] removing outlier

2015-09-11 Thread Juli
Hey, i want to remove outliers so I tried do do this: # 1 define mean and sd sd.AT_ZU_SPAET <- sd(AT_ZU_SPAET) mitt.AT_ZU_SPAET <- mean(AT_ZU_SPAET) # sd.Anzahl_BAF <- sd(Anzahl_BAF) mitt.Anzahl_BAF <- mean(Anzahl_BAF) # sd.Änderungsintervall <- sd(Änderungsintervall) mitt.Änderungsintervall <-

Re: [R] Removing display of R row names from list.

2015-07-30 Thread PIKAL Petr
essage- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > Frederic Ntirenganya > Sent: Thursday, July 30, 2015 10:41 AM > To: Bert Gunter > Cc: r-help@r-project.org > Subject: Re: [R] Removing display of R row names from list. > > I want to remove

  1   2   3   4   5   6   >