In the plot generated by ggplot, each label along the x-axis is a string, i.e., “the product in 1990”. However, the generated plot there is a period in between each word. In other words, the above string is shown as “the.product.in.1990”
How can I ensure the above “.” is not added?
The following code is what I used to add string for each point along the x-axis
last_plot()+scale_x_discrete(limits=ddata$labels$text)
Sample code:
library(ggdendro)
x <- read.csv("test.csv",header=TRUE)
d <- as.dist(x,diag=FALSE,upper=FALSE)
hc <- hclust(d,"ave")
dhc <- as.dendrogram(hc)
ddata <- dendro_data(dhc,type="rectangle")
ggplot(segment(ddata)) + geom_segment(aes(x=x0,y=y0,xend=x1,yend=y1))
last_plot() + scale_x_discrete(limits=ddata$labels$text)
each row of ddata$labels$text
is a string, like "the product in 1990".
I would like to keep the same format in the generated plot rather than "the.product.in.1990"