

Hi,
How do I extract just numbers from the following list:
a=c("<0.1",NA,0.3,5,Nil)
so I want to obtain: 0.3 and 5 from the above list
Thanks

Le gach dea ghui,
*Shane Carey*
*GIS and Data Solutions Consultant*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


> a < c("<0.1", NA, 0.3, 5, "Nil")
> a
[1] "<0.1" NA "0.3" "5" "Nil"
> b < as.numeric(a)
Warning message:
NAs introduced by coercion
> b
[1] NA NA 0.3 5.0 NA
> b[! is.na(b)]
[1] 0.3 5.0
B.
> On Sep 22, 2017, at 11:48 AM, Shane Carey < [hidden email]> wrote:
>
> Hi,
>
> How do I extract just numbers from the following list:
>
> a=c("<0.1",NA,0.3,5,Nil)
>
> so I want to obtain: 0.3 and 5 from the above list
>
> Thanks
>
>
> 
> Le gach dea ghui,
> *Shane Carey*
> *GIS and Data Solutions Consultant*
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Super,
Thanks
On Fri, Sep 22, 2017 at 4:57 PM, Boris Steipe < [hidden email]>
wrote:
> > a < c("<0.1", NA, 0.3, 5, "Nil")
> > a
> [1] "<0.1" NA "0.3" "5" "Nil"
>
> > b < as.numeric(a)
> Warning message:
> NAs introduced by coercion
> > b
> [1] NA NA 0.3 5.0 NA
>
> > b[! is.na(b)]
> [1] 0.3 5.0
>
>
> B.
>
>
> > On Sep 22, 2017, at 11:48 AM, Shane Carey < [hidden email]> wrote:
> >
> > Hi,
> >
> > How do I extract just numbers from the following list:
> >
> > a=c("<0.1",NA,0.3,5,Nil)
> >
> > so I want to obtain: 0.3 and 5 from the above list
> >
> > Thanks
> >
> >
> > 
> > Le gach dea ghui,
> > *Shane Carey*
> > *GIS and Data Solutions Consultant*
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/rhelp> > PLEASE do read the posting guide http://www.Rproject.org/> postingguide.html
> > and provide commented, minimal, selfcontained, reproducible code.
>
>

Le gach dea ghui,
*Shane Carey*
*GIS and Data Solutions Consultant*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hi,
Lets say this was a dataframe where I had two columns
a < c("<0.1", NA, 0.3, 5, "Nil")
b < c("<0.1", 1, 0.3, 5, "Nil")
And I just want to remove the rows from the dataframe where there were NAs
in the b column, what is the syntax for doing that?
Thanks in advance
On Fri, Sep 22, 2017 at 5:04 PM, Shane Carey < [hidden email]> wrote:
> Super,
>
> Thanks
>
> On Fri, Sep 22, 2017 at 4:57 PM, Boris Steipe < [hidden email]>
> wrote:
>
>> > a < c("<0.1", NA, 0.3, 5, "Nil")
>> > a
>> [1] "<0.1" NA "0.3" "5" "Nil"
>>
>> > b < as.numeric(a)
>> Warning message:
>> NAs introduced by coercion
>> > b
>> [1] NA NA 0.3 5.0 NA
>>
>> > b[! is.na(b)]
>> [1] 0.3 5.0
>>
>>
>> B.
>>
>>
>> > On Sep 22, 2017, at 11:48 AM, Shane Carey < [hidden email]> wrote:
>> >
>> > Hi,
>> >
>> > How do I extract just numbers from the following list:
>> >
>> > a=c("<0.1",NA,0.3,5,Nil)
>> >
>> > so I want to obtain: 0.3 and 5 from the above list
>> >
>> > Thanks
>> >
>> >
>> > 
>> > Le gach dea ghui,
>> > *Shane Carey*
>> > *GIS and Data Solutions Consultant*
>> >
>> > [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/rhelp>> > PLEASE do read the posting guide http://www.Rproject.org/posti>> ngguide.html
>> > and provide commented, minimal, selfcontained, reproducible code.
>>
>>
>
>
> 
> Le gach dea ghui,
> *Shane Carey*
> *GIS and Data Solutions Consultant*
>

Le gach dea ghui,
*Shane Carey*
*GIS and Data Solutions Consultant*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


myDF < data.frame(a = c("<0.1", NA, 0.3, 5, "Nil"),
b = c("<0.1", 1, 0.3, 5, "Nil"),
stringsAsFactors = FALSE)
# you can subset the bcolumn in several ways
myDF[ , 2]
myDF[ , "b"]
myDF$b
# using the column, you make a logical vector
! is.na(as.numeric(myDF$b))
# This can be used to select the rows you want
myDF[! is.na(as.numeric(myDF$b)), ]
B.
> On Sep 25, 2017, at 7:30 AM, Shane Carey < [hidden email]> wrote:
>
> Hi,
>
> Lets say this was a dataframe where I had two columns
>
> a < c("<0.1", NA, 0.3, 5, "Nil")
> b < c("<0.1", 1, 0.3, 5, "Nil")
>
> And I just want to remove the rows from the dataframe where there were NAs in the b column, what is the syntax for doing that?
>
> Thanks in advance
>
> On Fri, Sep 22, 2017 at 5:04 PM, Shane Carey < [hidden email]> wrote:
> Super,
>
> Thanks
>
> On Fri, Sep 22, 2017 at 4:57 PM, Boris Steipe < [hidden email]> wrote:
> > a < c("<0.1", NA, 0.3, 5, "Nil")
> > a
> [1] "<0.1" NA "0.3" "5" "Nil"
>
> > b < as.numeric(a)
> Warning message:
> NAs introduced by coercion
> > b
> [1] NA NA 0.3 5.0 NA
>
> > b[! is.na(b)]
> [1] 0.3 5.0
>
>
> B.
>
>
> > On Sep 22, 2017, at 11:48 AM, Shane Carey < [hidden email]> wrote:
> >
> > Hi,
> >
> > How do I extract just numbers from the following list:
> >
> > a=c("<0.1",NA,0.3,5,Nil)
> >
> > so I want to obtain: 0.3 and 5 from the above list
> >
> > Thanks
> >
> >
> > 
> > Le gach dea ghui,
> > *Shane Carey*
> > *GIS and Data Solutions Consultant*
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/rhelp> > PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> > and provide commented, minimal, selfcontained, reproducible code.
>
>
>
>
> 
> Le gach dea ghui,
> Shane Carey
> GIS and Data Solutions Consultant
>
>
>
> 
> Le gach dea ghui,
> Shane Carey
> GIS and Data Solutions Consultant
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


This is super, really helpfull. Sorry, one final question, lets say I
wanted to remove 0's rather than NAs , what would it be?
Thanks
On Mon, Sep 25, 2017 at 12:41 PM, Boris Steipe < [hidden email]>
wrote:
> myDF < data.frame(a = c("<0.1", NA, 0.3, 5, "Nil"),
> b = c("<0.1", 1, 0.3, 5, "Nil"),
> stringsAsFactors = FALSE)
>
> # you can subset the bcolumn in several ways
>
> myDF[ , 2]
> myDF[ , "b"]
> myDF$b
>
> # using the column, you make a logical vector
> ! is.na(as.numeric(myDF$b))
>
>
> # This can be used to select the rows you want
>
> myDF[! is.na(as.numeric(myDF$b)), ]
>
>
>
> B.
>
>
> > On Sep 25, 2017, at 7:30 AM, Shane Carey < [hidden email]> wrote:
> >
> > Hi,
> >
> > Lets say this was a dataframe where I had two columns
> >
> > a < c("<0.1", NA, 0.3, 5, "Nil")
> > b < c("<0.1", 1, 0.3, 5, "Nil")
> >
> > And I just want to remove the rows from the dataframe where there were
> NAs in the b column, what is the syntax for doing that?
> >
> > Thanks in advance
> >
> > On Fri, Sep 22, 2017 at 5:04 PM, Shane Carey < [hidden email]>
> wrote:
> > Super,
> >
> > Thanks
> >
> > On Fri, Sep 22, 2017 at 4:57 PM, Boris Steipe < [hidden email]>
> wrote:
> > > a < c("<0.1", NA, 0.3, 5, "Nil")
> > > a
> > [1] "<0.1" NA "0.3" "5" "Nil"
> >
> > > b < as.numeric(a)
> > Warning message:
> > NAs introduced by coercion
> > > b
> > [1] NA NA 0.3 5.0 NA
> >
> > > b[! is.na(b)]
> > [1] 0.3 5.0
> >
> >
> > B.
> >
> >
> > > On Sep 22, 2017, at 11:48 AM, Shane Carey < [hidden email]> wrote:
> > >
> > > Hi,
> > >
> > > How do I extract just numbers from the following list:
> > >
> > > a=c("<0.1",NA,0.3,5,Nil)
> > >
> > > so I want to obtain: 0.3 and 5 from the above list
> > >
> > > Thanks
> > >
> > >
> > > 
> > > Le gach dea ghui,
> > > *Shane Carey*
> > > *GIS and Data Solutions Consultant*
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > [hidden email] mailing list  To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/rhelp> > > PLEASE do read the posting guide http://www.Rproject.org/> postingguide.html
> > > and provide commented, minimal, selfcontained, reproducible code.
> >
> >
> >
> >
> > 
> > Le gach dea ghui,
> > Shane Carey
> > GIS and Data Solutions Consultant
> >
> >
> >
> > 
> > Le gach dea ghui,
> > Shane Carey
> > GIS and Data Solutions Consultant
>
>

Le gach dea ghui,
*Shane Carey*
*GIS and Data Solutions Consultant*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Always via logical expressions. In this case you can use the logical expression
myDF$b != "0"
to give you a vector of TRUE/FALSE
B.
> On Sep 25, 2017, at 8:00 AM, Shane Carey < [hidden email]> wrote:
>
> This is super, really helpfull. Sorry, one final question, lets say I wanted to remove 0's rather than NAs , what would it be?
>
> Thanks
>
> On Mon, Sep 25, 2017 at 12:41 PM, Boris Steipe < [hidden email]> wrote:
> myDF < data.frame(a = c("<0.1", NA, 0.3, 5, "Nil"),
> b = c("<0.1", 1, 0.3, 5, "Nil"),
> stringsAsFactors = FALSE)
>
> # you can subset the bcolumn in several ways
>
> myDF[ , 2]
> myDF[ , "b"]
> myDF$b
>
> # using the column, you make a logical vector
> ! is.na(as.numeric(myDF$b))
>
>
> # This can be used to select the rows you want
>
> myDF[! is.na(as.numeric(myDF$b)), ]
>
>
>
> B.
>
>
> > On Sep 25, 2017, at 7:30 AM, Shane Carey < [hidden email]> wrote:
> >
> > Hi,
> >
> > Lets say this was a dataframe where I had two columns
> >
> > a < c("<0.1", NA, 0.3, 5, "Nil")
> > b < c("<0.1", 1, 0.3, 5, "Nil")
> >
> > And I just want to remove the rows from the dataframe where there were NAs in the b column, what is the syntax for doing that?
> >
> > Thanks in advance
> >
> > On Fri, Sep 22, 2017 at 5:04 PM, Shane Carey < [hidden email]> wrote:
> > Super,
> >
> > Thanks
> >
> > On Fri, Sep 22, 2017 at 4:57 PM, Boris Steipe < [hidden email]> wrote:
> > > a < c("<0.1", NA, 0.3, 5, "Nil")
> > > a
> > [1] "<0.1" NA "0.3" "5" "Nil"
> >
> > > b < as.numeric(a)
> > Warning message:
> > NAs introduced by coercion
> > > b
> > [1] NA NA 0.3 5.0 NA
> >
> > > b[! is.na(b)]
> > [1] 0.3 5.0
> >
> >
> > B.
> >
> >
> > > On Sep 22, 2017, at 11:48 AM, Shane Carey < [hidden email]> wrote:
> > >
> > > Hi,
> > >
> > > How do I extract just numbers from the following list:
> > >
> > > a=c("<0.1",NA,0.3,5,Nil)
> > >
> > > so I want to obtain: 0.3 and 5 from the above list
> > >
> > > Thanks
> > >
> > >
> > > 
> > > Le gach dea ghui,
> > > *Shane Carey*
> > > *GIS and Data Solutions Consultant*
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > [hidden email] mailing list  To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/rhelp> > > PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> > > and provide commented, minimal, selfcontained, reproducible code.
> >
> >
> >
> >
> > 
> > Le gach dea ghui,
> > Shane Carey
> > GIS and Data Solutions Consultant
> >
> >
> >
> > 
> > Le gach dea ghui,
> > Shane Carey
> > GIS and Data Solutions Consultant
>
>
>
>
> 
> Le gach dea ghui,
> Shane Carey
> GIS and Data Solutions Consultant
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Super, thanks Boris. Top notch :)
On Mon, Sep 25, 2017 at 1:05 PM, Boris Steipe < [hidden email]>
wrote:
> Always via logical expressions. In this case you can use the logical
> expression
>
> myDF$b != "0"
>
> to give you a vector of TRUE/FALSE
>
>
>
> B.
>
>
> > On Sep 25, 2017, at 8:00 AM, Shane Carey < [hidden email]> wrote:
> >
> > This is super, really helpfull. Sorry, one final question, lets say I
> wanted to remove 0's rather than NAs , what would it be?
> >
> > Thanks
> >
> > On Mon, Sep 25, 2017 at 12:41 PM, Boris Steipe < [hidden email]>
> wrote:
> > myDF < data.frame(a = c("<0.1", NA, 0.3, 5, "Nil"),
> > b = c("<0.1", 1, 0.3, 5, "Nil"),
> > stringsAsFactors = FALSE)
> >
> > # you can subset the bcolumn in several ways
> >
> > myDF[ , 2]
> > myDF[ , "b"]
> > myDF$b
> >
> > # using the column, you make a logical vector
> > ! is.na(as.numeric(myDF$b))
> >
> >
> > # This can be used to select the rows you want
> >
> > myDF[! is.na(as.numeric(myDF$b)), ]
> >
> >
> >
> > B.
> >
> >
> > > On Sep 25, 2017, at 7:30 AM, Shane Carey < [hidden email]> wrote:
> > >
> > > Hi,
> > >
> > > Lets say this was a dataframe where I had two columns
> > >
> > > a < c("<0.1", NA, 0.3, 5, "Nil")
> > > b < c("<0.1", 1, 0.3, 5, "Nil")
> > >
> > > And I just want to remove the rows from the dataframe where there were
> NAs in the b column, what is the syntax for doing that?
> > >
> > > Thanks in advance
> > >
> > > On Fri, Sep 22, 2017 at 5:04 PM, Shane Carey < [hidden email]>
> wrote:
> > > Super,
> > >
> > > Thanks
> > >
> > > On Fri, Sep 22, 2017 at 4:57 PM, Boris Steipe <
> [hidden email]> wrote:
> > > > a < c("<0.1", NA, 0.3, 5, "Nil")
> > > > a
> > > [1] "<0.1" NA "0.3" "5" "Nil"
> > >
> > > > b < as.numeric(a)
> > > Warning message:
> > > NAs introduced by coercion
> > > > b
> > > [1] NA NA 0.3 5.0 NA
> > >
> > > > b[! is.na(b)]
> > > [1] 0.3 5.0
> > >
> > >
> > > B.
> > >
> > >
> > > > On Sep 22, 2017, at 11:48 AM, Shane Carey < [hidden email]>
> wrote:
> > > >
> > > > Hi,
> > > >
> > > > How do I extract just numbers from the following list:
> > > >
> > > > a=c("<0.1",NA,0.3,5,Nil)
> > > >
> > > > so I want to obtain: 0.3 and 5 from the above list
> > > >
> > > > Thanks
> > > >
> > > >
> > > > 
> > > > Le gach dea ghui,
> > > > *Shane Carey*
> > > > *GIS and Data Solutions Consultant*
> > > >
> > > > [[alternative HTML version deleted]]
> > > >
> > > > ______________________________________________
> > > > [hidden email] mailing list  To UNSUBSCRIBE and more, see
> > > > https://stat.ethz.ch/mailman/listinfo/rhelp> > > > PLEASE do read the posting guide http://www.Rproject.org/> postingguide.html
> > > > and provide commented, minimal, selfcontained, reproducible code.
> > >
> > >
> > >
> > >
> > > 
> > > Le gach dea ghui,
> > > Shane Carey
> > > GIS and Data Solutions Consultant
> > >
> > >
> > >
> > > 
> > > Le gach dea ghui,
> > > Shane Carey
> > > GIS and Data Solutions Consultant
> >
> >
> >
> >
> > 
> > Le gach dea ghui,
> > Shane Carey
> > GIS and Data Solutions Consultant
>
>

Le gach dea ghui,
*Shane Carey*
*GIS and Data Solutions Consultant*
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


You realize, do you not, that in fact there are no numbers in your "list"
(actually a vector).
It looks like you would do well to spend some time with an R tutorial or
two before posting further to this list. We can help, but cannot substitute
for the basic knowledge that you would gain from doing this.
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
 Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Mon, Sep 25, 2017 at 4:30 AM, Shane Carey < [hidden email]> wrote:
> Hi,
>
> Lets say this was a dataframe where I had two columns
>
> a < c("<0.1", NA, 0.3, 5, "Nil")
> b < c("<0.1", 1, 0.3, 5, "Nil")
>
> And I just want to remove the rows from the dataframe where there were NAs
> in the b column, what is the syntax for doing that?
>
> Thanks in advance
>
> On Fri, Sep 22, 2017 at 5:04 PM, Shane Carey < [hidden email]> wrote:
>
> > Super,
> >
> > Thanks
> >
> > On Fri, Sep 22, 2017 at 4:57 PM, Boris Steipe < [hidden email]>
> > wrote:
> >
> >> > a < c("<0.1", NA, 0.3, 5, "Nil")
> >> > a
> >> [1] "<0.1" NA "0.3" "5" "Nil"
> >>
> >> > b < as.numeric(a)
> >> Warning message:
> >> NAs introduced by coercion
> >> > b
> >> [1] NA NA 0.3 5.0 NA
> >>
> >> > b[! is.na(b)]
> >> [1] 0.3 5.0
> >>
> >>
> >> B.
> >>
> >>
> >> > On Sep 22, 2017, at 11:48 AM, Shane Carey < [hidden email]>
> wrote:
> >> >
> >> > Hi,
> >> >
> >> > How do I extract just numbers from the following list:
> >> >
> >> > a=c("<0.1",NA,0.3,5,Nil)
> >> >
> >> > so I want to obtain: 0.3 and 5 from the above list
> >> >
> >> > Thanks
> >> >
> >> >
> >> > 
> >> > Le gach dea ghui,
> >> > *Shane Carey*
> >> > *GIS and Data Solutions Consultant*
> >> >
> >> > [[alternative HTML version deleted]]
> >> >
> >> > ______________________________________________
> >> > [hidden email] mailing list  To UNSUBSCRIBE and more, see
> >> > https://stat.ethz.ch/mailman/listinfo/rhelp> >> > PLEASE do read the posting guide http://www.Rproject.org/posti> >> ngguide.html
> >> > and provide commented, minimal, selfcontained, reproducible code.
> >>
> >>
> >
> >
> > 
> > Le gach dea ghui,
> > *Shane Carey*
> > *GIS and Data Solutions Consultant*
> >
>
>
>
> 
> Le gach dea ghui,
> *Shane Carey*
> *GIS and Data Solutions Consultant*
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/> postingguide.html
> and provide commented, minimal, selfcontained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

