Skip to content
Prev 389182 / 398506 Next

How to remove all rows that have a numeric in the first (or any) column

On Wed, 15 Sep 2021 02:01:53 +0000
Gregg Powell via R-help <r-help at r-project.org> wrote:

            
Do you mean that the HVA column *is* a list? It probably shouldn't be.
It seems very likely that your data are all screwed up.  The first
thing to do is get your data properly organised.  That could be
difficult since you have apparently read them in from an Excel file,
and Excel is a recipe for disaster.
No attachment came through.  Do read the posting guide.  Most
attachments are stripped by the mail handler.
If there are any non-numeric entries in a column then they *all* have
to be non-numeric.  Some of them *may* be interpretable as being
numeric.

If you apply as.numeric() to a column you'll get NA's for all entries
that *cannot* be interpreted as numeric. So you may want to do something
like (untested, of course):

ok <- is.na(as.numeric(X[,"HVA"]))
X  <- X[ok,]

where "X" is the data frame that you are dealing with.

Good luck.

cheers,

Rolf Turner
Message-ID: <20210915154124.5cb9eac2@rolf-Latitude-E7470>
In-Reply-To: <BKIgN44too4juT0O9jtdnxR_OTD1Lv28B0FB_2h8hR-ZmvAKtDa_s-U_mjfZeJzfAiQw5Er24aLme_rdK2Vf5xGdEwrXyD7mRrpGT66_okM=@protonmail.com>