Displaying 20 results from an estimated 20000 matches similar to: "ignorable warnings of as.numeric: NAs introduced by coercion"
2011 Jul 29
2
converting factor to numeric gives "NAs introduced by coercion"
Hi,
I have a dataframe that I imported from a .txt file by:
skogTemp <- read.delim2("Skogaryd_shoot_data.txt", header=TRUE, fill=TRUE)
and the data are factors, how can avoid factors from the beginning? Although
the file contains both characters and numbers.
I tried to convert some of the columns from factor to numeric and as I
understood it you can not use only as.numeric but
2009 Nov 23
1
NAs introduced by coercion warning?
An embedded and charset-unspecified text was scrubbed...
Name: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091123/a7856456/attachment-0001.pl>
2008 Mar 11
1
NAs introduced by coercion
Hallo,
i get a warning message that NAs are introduced by coercion,
so my idea is to write a function to see which values are turned into
NA
For this i need to write a function to go through (loop) the original
data and the transformed (with the introduced na) to see which data were
transformed to NA.
So the return of this function should be a 2*many matrix like structure,
eg
names:
2012 Jul 29
1
readRDS, In as.double.xts(fishReport$count) : NAs introduced by coercion
Hello,
I looked in the R-help but could not find an archive addressing the
following. I would like to convert a character to numeric after reading a
file with RDS extension. After using as.numeric, I checked if it is
numeric. It was not converted. Please help.
Here is my code
>Report <- readRDS(file="RDS/Report.RDS")
> Report[1:2,]
dive_id date
2007 May 02
2
NAs introduced by coercion in dist()
I work with Windows and use R version 2.4.1. I am JUST starting to learn this
program...
I get this warning message 'NAs introduced by coercion' while trying to
build a distance matrix (to be analyzed with NMDS later) from a 336 x 100
data matrix. The original matrix has lots of zeros and no missing values,
but I don't think this should matter.
I searched this forum and people have
2002 May 03
2
sub() of matrix returns a vector and not a matrix
Is there a simple possibility
to become directly a matrix
from a call of sub() on a matrix?
--------- START OF LOGFILE ----------------
# R 1.4.1
> a <- matrix( letters[1:6], 2, 3 )
# a is a matrix
> print( a )
[,1] [,2] [,3]
[1,] "a" "c" "e"
[2,] "b" "d" "f"
> b <- sub( '(.)', '-\\1-', a )
2004 Oct 04
11
inverse function of order()
I have:
d <- sample(10:100, 9)
o <- order(d)
r <- d[o]
How I can get d (in the original order), knowing only r and o?
Thanks - Wolfram
2010 Apr 09
3
using as.numeric() without generating warning message
I'm interested in testing whether or not a character string is numeric or
not as follows:
is.na(as.numeric('3')) # returns F
is.na(as.numeric('A')) # I'd like this to return T without issuing a warning
about NAs introduced by coercion.
I guess you could suppress the warning with options(warn=-1), but I was
wondering if there's an alternative. Or perhaps an
2003 Jan 24
4
new function: showcolors {base}
I propose to add a function that allows
to display colors selected by a text pattern
or by color vectors in a plot.
Wolfram Fischer
#--- showcolors.R
showcolors <-
function(
col = "red"
, index = NULL
, pie = TRUE
, lwd = 6
, cex = 1.0
, main = NULL
, sub = NULL
, ...
){
n.colors <- length( col )
if( n.colors > 1 ){
main <- deparse( substitute( col ) )
2006 Nov 29
4
Why the factor levels returned by cut() are not ordered?
What is the reason, that the levels of the factor
returned by cut() are not marked as ordered levels?
> is.ordered( cut( breaks=3, sample(10 ) ) )
FALSE
> help(factor)
...
If 'ordered' is 'TRUE', the factor levels are assumed to be ordered.
...
Wolfram
2005 Apr 11
6
How to change letters after space into capital letters
What is the easiest way to change within vector of strings
each letter after a space into a capital letter?
E.g.:
c( "this is an element of the vector of strings", "second element" )
becomes:
c( "This Is An Element Of The Vector Of Strings", "Second Element" )
My reason to try to do this is to get more readable abbreviations.
(A suggestion would be to
2005 Nov 14
2
Coercion of percentages by as.numeric
Hi
Given that things like the following work
> a <- c("-.1"," 2.7 ","B")
> a
[1] "-.1" " 2.7 " "B"
> as.numeric(a)
[1] -0.1 2.7 NA
Warning message:
NAs introduced by coercion
>
I naively expected that the following would behave differently.
> b <- c('10%', '-20%', '30.0%',
2009 Jun 04
1
how to tell if as.numeric succeeds?
Suppose I have a vector of strings. I'd like to convert this to a vector of
numbers if possible. How can I tell if it is possible?
as.numeric() will issue a warning if it fails. Do I need to trap this
warning? If so, how?
In other words, my end goal is a function that takes a vector of strings and
returns either a numeric vector or the original vector. Assuming this
doesn't already
2003 Aug 29
2
length() and nchar()
I would propose to add "
See also:
`nchar' for counting the number of character in
character vectors.
"
to the helpfile of length(),
because it is rather difficult
to find nchar() if one has only
search terms as "length", "len",
"strlen" in mind.
Sincerly
Wolfram Fischer
2004 Dec 07
1
how to test the existence of a name in a dataframe
I wanted to test if there exists already a name (which is
incidentally a substring of another name) in a dataframe.
I did e.g.:
> data(swiss)
> names(swiss)
[1] "Fertility" "Agriculture" "Examination" "Education"
[5] "Catholic" "Infant.Mortality"
> ! is.null(swiss$EduX)
[1] FALSE
> !
2005 Apr 15
4
function corresponding to map of perl
Is there a function in R that corresponds to the
function ``map'' of perl?
It could be called like:
vector.a <- map( vector.b, FUN, args.for.FUN )
It should execute for each element ele.b of vector.b:
FUN( vector.b, args.for.FUN)
It should return a vector (or data.frame) of the results
of the calls of FUN.
It nearly works using:
apply( data.frame( vector.b ), 1, FUN,
2006 Dec 08
1
lattice: defining an own function using args for "formula" and "groups"
x.fun <- function( formula, data ) dotplot( formula, data )
x.grp <- function( formula, groups, data ) dotplot( formula, groups, data )
data( barley )
> x.fun( variety ~ yield | site, data=barley )
# no problem
> dotplot( variety ~ yield | site, groups=year, data=barley )
# no problem
> x.grp( variety ~ yield | site, groups=year, data=barley )
object "year" not found
2010 Feb 16
3
margin text warning message NAs coercion
Readers,
I tried to the following commands:
plot(y~x,ylab=expression(A[1]~B[2],xlab=expression(C~D))
mtext(expression(A[1]~B[2]),"additional text",side=3,line=1)
I receive the text that I want, but the command terminal shows the
following response:
Warning message:
NAs introduced by coercion in: mtext(expression(A[1]~B[2]),"additional
text", side = 3,
What is my mistake
2007 Feb 15
2
Problems with 'delay'/'delayedAssign' when installing data package
I downloaded:
http://www.bioconductor.org/data/metaData/hgu95av2_1.7.0.tar.gz
described as:
Package: hgu95av2
Title: A data package containing annotation data for hgu95av2
Version: 1.7.0
Created: Wed Jan 12 16:57:23 2005
Author: Lin,Chenwei
Description: Annotation data file for hgu95av2 assembled using data
from public data repositories
Maintainer:
2002 May 21
1
plotting functions with line width (lwd) as vectors
If I want to plot different widths of line segments or arrows
I have to program loops to plot each line apartly. Is that
right?
n <- 6
x <- 1:n
y <- rnorm(1:n)
q <- ( x %% 3 + 1 ) * 2
plot( x, y, cex=q )
for( i in 1:(n-1) ) lines( x[i:(i+1)], y[i:(i+1)], lwd=q[i], col=q[i] )
Would it not be possible to make plotting functions accept
vectors of line widths (as they