Error In Xy.coordsx Y Xlabel Ylabel Log
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the error in stripchart.default(x1, ...) : invalid plotting method company Business Learn more about hiring developers or posting ads with us Stack Overflow
Plot List In R
Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7
Error In Plot.window(...) : Need Finite 'xlim' Values
million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up 'x' and 'y' lengths differ ERROR up vote 0 down vote favorite I just started using R. I am
Plot Type In R
supposed to Calculate a new variable “Vehic_vol” from the sum of “Psgr_Vol” and “Lugg_Vol” and Plot this new variable against “CITY_MPG” for the whole data set but I end up with 'x' and 'y' lengths differ ERROR! Any thoughts? Here is what I did: Vehic_vol<-(VehicleData$Psgr_Vol + VehicleData$Lugg_Vol) plot (VehicleData$Vehic_vol, VehicleData$CITY_MPG) Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ r share|improve this question edited May 16 '15 at 23:45 plotting in r Maven 324513 asked Jan 15 '15 at 17:30 Farshad 514 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted From the code you provided, Vehic_vol is not a column of VehicleData. If you enter in VehicleData$Vehic_vol it returns NULL Note that NULL and VehicleData$CITY_MPG have different lengths (use length() to verify that). Try this instead plot (Vehic_vol, VehicleData$CITY_MPG) or VehicleData$Vehic_vol <- (VehicleData$Psgr_Vol + VehicleData$Lugg_Vol) plot (VehicleData$Vehic_vol, VehicleData$CITY_MPG) share|improve this answer answered Jan 15 '15 at 17:38 blakeoft 1,205413 General rule suggestion: In my R code I tend to separate a "add derived values to my dataframe" phase from a "now use the extended stuff for plotting" phase. In this manner of working you would have written VehicleData$Vehic_vol <- (VehicleData$Psgr_Vol + VehicleData$Lugg_Vol) (variant 2 of above) and the subsequent plot command would have worked as you wanted it to as a matter of course (without straining your short term memory much). –Lutz Prechelt Jan 16 '15 at 18:54 Thanks for help –Farshad Jan 18 '15 at 1:42 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest
# # adityashrm21 2015-07-08 12:37:00 UTC #1 scatterplot in r Hello, I was trying to implement K-means algorithm with a dataset. sub=sample_n(train,100)kmeansdata=data.frame(sub$temp,sub$humidity)kmeans=kmeans(kmeansdata,centers=3)kmeans$centers sub.temp sub.humidity1 23.37000 http://stackoverflow.com/questions/27969434/x-and-y-lengths-differ-error 35.076922 20.28839 56.806453 19.16512 81.53488plot(kmeans) and I am getting an error saying Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' https://discuss.analyticsvidhya.com/t/error-in-xy-coords-x-y-xlabel-ylabel-log-x-is-a-list-but-does-not-have-components-x-and-y-while-trying-to-implement-k-means-algorithm-in-r/2165 and 'y' Why is this error coming and how to remove it? Thanks. ajay_ohri 2015-07-12 16:31:36 UTC #2 you need to specify x, y data for plot command . if you see you have just specified kmeans and it will have a list of data you need to be more clear instead try and do kmeans with the rattle GUI package Home Categories FAQ/Guidelines Terms of Service Privacy Policy Powered by Discourse, best viewed with JavaScript enabled Home Blog Jobs DataHack Trainings Learning Paths Forget Password j
von GoogleAnmeldenAusgeblendete FelderNach Gruppen oder Nachrichten suchen
From: Daniel Malter Date: Thu, 16 Jun 2011 23:30:48 -0700 (PDT) It likely means that your x and y are differently long. That is, affect1 and adh1scr do not contain the same number of values in that instance. That precludes them from being plotted against each other. abline and lowess would fail for the same reason. x<-c(1,2,3) y<-c(2,4) plot(y~x) complete.cases(x,y) However, what is peculiar about this is that if x and y indeed have different length, the complete.cases() function should fail (unless specified with some override argument). The problem is definitely NOT one with XLIM or YLIM. HTH, Daniel Alspach, Steven E. wrote: > > Hello, > > > > I am working on a project to create some scatter plots. I have syntax > for 26 plots, and 22 of them display as they should. But here, for > example, is a sample of the command syntax I am using: > > > > good <- complete.cases(affect1,adh1scr) > > plot > (jitter(affect1,2.0),jitter(adh1scr,1.0),xlim=c(1,35),ylim=c(1,35),pch=1 > 6, > > main='Adherence Score by Affectiveness Level - Visit 1', > > ylab='Adherence score',xlab='Affect Scale - Patient > Survey',abline(lsfit(affect1,adh1scr)),col="red") > > lines(lowess(affect1[good], adh1scr[good]), col="blue") > > > > I run this and get: > > > >> good <- complete.cases(affect1,adh1scr) > >> plot > (jitter(affect1,2.0),jitter(adh1scr,1.0),xlim=c(1,35),ylim=c(1,35),pch=1 > 6, > > + main='Adherence Score by Affectiveness Level - Visit 1', > > + ylab='Adherence score',xlab='Affect Scale - Patient > Survey',abline(lsfit(affect1,adh1scr)),col="red") > > Error in xy.coords(x, y, xlabel, ylabel, log) : > > 'x' and 'y' lengths differ > >> lines(lowess(affect1[good], adh1scr[good]), col="blue") > > Error in xy.coords(x, y) : 'x' and 'y' lengths differ > > > > The data is a bit skewed towards the high end, but I found other > variables that skew even more and they produce graphs. I've taken out > the ABLINE and LINES options and the problem persists. I tried changing > the name of the AFFECT1 variable, the problem exists. I tried changing > the values of XLIM and YLIM (the range for the X and Y variables are > both 1 and 35); I still get the same error. There are enough valid > cases to create a scatter plot (two of the plots will have 211 valid > cases, the other two will have 163 valid cases). > > > > This occurs in the middle of my command file. So - I know that the > variable