[R] NAs introduced by coercion warning, while plotting data

Dániel Kehl kehld at ktk.pte.hu
Tue Jan 7 16:18:21 CET 2014


Hi,

are you reading only one cell of your Excel file?
It seems your datalist is not numeric but text.
Try saving your Excel file as csv or text, reading in data might be much more straightforward!

best
daniel
________________________________________
Feladó: r-help-bounces at r-project.org [r-help-bounces at r-project.org] ; meghatalmazó: Baro [babakbsn at gmail.com]
Küldve: 2014. január 7. 16:01
To: PIKAL Petr
Cc: R help
Tárgy: Re: [R] NAs introduced by coercion warning, while plotting data

thank you for your answer, I am reading my Data from an excel File. This is
my R code:

srow<-2421
wb <- loadWorkbook("C:\\users\\Babak\\Desktop\\spalte205.xls")
dat <-readWorksheet(wb, sheet=getSheets(wb)[1], startRow=srow, endRow=srow,
startCol=spalte, endCol=spalte,header=FALSE)
datalist<-dat[,1]
datalist<-sub(";","",datalist)
datalist
plot(datalist,type="l",ylim=c(-1,+1))

as an output of my data, I see:

> datalist
[1] " 7.0121, -0.673354, 0.749622, -0.549641, 0.435662, -0.328995,
0.0869976, -0.0851428, -0.191019, 0.188799, -0.373707, 0.434814, -0.51979,
0.61944, -0.554766, 0.662571, -0.557779, 0.543724, -0.452397, 0.293651,
-0.248438, 0.0532787, -0.0185775, -0.176117, 0.222021, -0.34723, 0.407796,
-0.416123, 0.497159, -0.435225, 0.473375, -0.370811, 0.33683, -0.273933,
0.149871, -0.142623, -0.0253748, 0.0205145, -0.134123, 0.167995, -0.209844,
0.266891, -0.242527, 0.326598, -0.235483, 0.275738, -0.195738, 0.168225,
-0.114333, 0.0593316, -0.0583527, -0.016594, 0.0363428, -0.0533603,
0.106158, -0.129363, 0.131993, -0.134909, 0.135686, -0.125387, 0.0866545,
-0.0668686, 0.043161, -0.0229738  "




On Tue, Jan 7, 2014 at 6:54 AM, PIKAL Petr <petr.pikal at precheza.cz> wrote:

> Hi
>
> I did not get any error with your data
>
> plot(test)
>
> dput(test)
> c(7.0121, -0.673354, 0.749622, -0.549641, 0.435662, -0.328995,
> 0.0869976, -0.0851428, -0.191019, 0.188799, -0.373707, 0.434814,
> -0.51979, 0.61944, -0.554766, 0.662571, -0.557779, 0.543724,
> -0.452397, 0.293651, -0.248438, 0.0532787, -0.0185775, -0.176117,
> 0.222021, -0.34723, 0.407796, -0.416123, 0.497159, -0.435225,
> 0.473375, -0.370811, 0.33683, -0.273933, 0.149871, -0.142623,
> -0.0253748, 0.0205145, -0.134123, 0.167995, -0.209844, 0.266891,
> -0.242527, 0.326598, -0.235483, 0.275738, -0.195738, 0.168225,
> -0.114333, 0.0593316, -0.0583527, -0.016594, 0.0363428, -0.0533603,
> 0.106158, -0.129363, 0.131993, -0.134909, 0.135686, -0.125387,
> 0.0866545, -0.0668686, 0.043161, -0.0229738)
>
> You shall explain more clearly what you did (code) and what are your data
> (dput)
>
> I presume that the story is not as simple as plotting a vector as you have
> suggested.
>
> Petr
>
> > -----Original Message-----
> > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> > project.org] On Behalf Of Baro
> > Sent: Tuesday, January 07, 2014 3:40 PM
> > To: R help
> > Subject: [R] NAs introduced by coercion warning, while plotting data
> >
> > Hi all
> >
> > I have such a Data and I want to plot them but I get this warning
> >
> > Warning message:
> > In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
> >
> >
> > " 7.0121, -0.673354, 0.749622, -0.549641, 0.435662, -0.328995,
> > 0.0869976, -0.0851428, -0.191019, 0.188799, -0.373707, 0.434814, -
> > 0.51979, 0.61944, -0.554766, 0.662571, -0.557779, 0.543724, -0.452397,
> > 0.293651, -0.248438, 0.0532787, -0.0185775, -0.176117, 0.222021, -
> > 0.34723, 0.407796, -0.416123, 0.497159, -0.435225, 0.473375, -0.370811,
> > 0.33683, -0.273933, 0.149871, -0.142623, -0.0253748, 0.0205145, -
> > 0.134123, 0.167995, -0.209844, 0.266891, -0.242527, 0.326598, -
> > 0.235483, 0.275738, -0.195738, 0.168225, -0.114333, 0.0593316, -
> > 0.0583527, -0.016594, 0.0363428, -0.0533603, 0.106158, -0.129363,
> > 0.131993, -0.134909, 0.135686, -0.125387, 0.0866545, -0.0668686,
> > 0.043161, -0.0229738 "
> >
> > Why do I get this warning? how can I solve it?
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-
> > guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list