shaqifahsani
2013-May-05 12:20 UTC
[R] Error in plot.window(...) : need finite 'xlim' values
Hi, I am very new to R. I am planning to plot a dendrogram from a binary file but received error after running it. I retrieved the code from the Internet and customized it accordingly... Error: Error in plot.window(...) : need finite 'xlim' values Can you explain why and what should I do... Thank you :) code: # load required libraries library(cluster) # clustering functions library(ape) # plotting # retrieve csv data treePhone <- read.csv("J:/research/source/treePhone_binary.csv") # combine into single data.frame df_treePhone <- data.frame(treePhone) d_treePhone <- daisy(df_treePhone) # perform divisive hierarcical clustering for dendrogram creation di_treePhone.diana <- diana(d_treePhone) # convert object into 'phylo' class for plotting p_treePhone.phylo <- as.phylo(as.hclust(di_treePhone.diana)) # plot dendrogram representation, annotated with the same labels plot(p_treePhone.phylo) [[alternative HTML version deleted]]
Uwe Ligges
2013-May-05 20:19 UTC
[R] Error in plot.window(...) : need finite 'xlim' values
On 05.05.2013 14:20, shaqifahsani wrote:> Hi, > > I am very new to R. I am planning to plot a dendrogram from a binary file > but received error after running it. I retrieved the code from the Internet > and customized it accordingly... > > Error: Error in plot.window(...) : need finite 'xlim' values > > Can you explain why and what should I do... Thank you :)Please see the positng guide that asks for reproducible code.Yours is not since we have no "J:/research/source/treePhone_binary.csv". Best, Uwe Ligges> code: > > # load required libraries > library(cluster) # clustering functions > library(ape) # plotting > > # retrieve csv data > treePhone <- read.csv("J:/research/source/treePhone_binary.csv") > > # combine into single data.frame > df_treePhone <- data.frame(treePhone) > > d_treePhone <- daisy(df_treePhone) > > # perform divisive hierarcical clustering for dendrogram creation > di_treePhone.diana <- diana(d_treePhone) > > # convert object into 'phylo' class for plotting > p_treePhone.phylo <- as.phylo(as.hclust(di_treePhone.diana)) > > # plot dendrogram representation, annotated with the same labels > plot(p_treePhone.phylo) > > [[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. >
On 05/05/2013 10:20 PM, shaqifahsani wrote:> Hi, > > I am very new to R. I am planning to plot a dendrogram from a binary file > but received error after running it. I retrieved the code from the Internet > and customized it accordingly... > > Error: Error in plot.window(...) : need finite 'xlim' values > > Can you explain why and what should I do... Thank you :) > > code: > > # load required libraries > library(cluster) # clustering functions > library(ape) # plotting > > # retrieve csv data > treePhone<- read.csv("J:/research/source/treePhone_binary.csv") > > # combine into single data.frame > df_treePhone<- data.frame(treePhone) > > d_treePhone<- daisy(df_treePhone) > > # perform divisive hierarcical clustering for dendrogram creation > di_treePhone.diana<- diana(d_treePhone) > > # convert object into 'phylo' class for plotting > p_treePhone.phylo<- as.phylo(as.hclust(di_treePhone.diana)) > > # plot dendrogram representation, annotated with the same labels > plot(p_treePhone.phylo) >Hi shaqifahsani, This is almost certainly due to missing values in the final data structure "p_treePhone.phylo" (which may have propagated from missing values in the original data frame). I think that p_treePhone.phylo will probably have "x" and "y" components. You can see the structure with: str(p_treePhone.phylo) If there is a "$x" component, look at it with: p_treePhone$x If there are any NA or NaN or Inf values, this is your problem. You may be able to get around it with the "complete.cases" function. Jim