Reputation: 33
what I have tried is
reddit <-read.csv('movie_metadata.csv')
reddit <- na.omit(reddit)
View(reddit)
facebook<-reddit[1:50,c(2,9,23)]
samp2 <- facebook[,-2]
rownames(samp2) <- facebook[,2]
samp2
samp.with.rownames <- data.frame(facebook[,-2], row.names=facebook[,2])
row.names(facebook)<-reddit$director_name[1:50]
d<-dist(as.matrix(samp.with.rownames))
e<-log(d)
hc<-hclust(d)
plot(hc,cex=0.8,las=1)
even after different methods what I am getting is numbers instead of names or text present there in column 2
Upvotes: 0
Views: 74
Reputation: 2180
welcome to SO.
First of all, I quite don't understand why would you want to change index number to text. The text needs to be unique in order fot it to work and know, that director name won't be unique.
Instead, add a column with director name to the dataset and when you will be saving the dataframe, use:
write.csv(samp2, row.names = F)
The second thing, your example is not reproducible, which wouldn't be a problem if you included your purpose of changing the index to characters.
Here is something that could help you maybe?
try looking into ?hclust
Maybe what you need is create data frame with 2 columns, use 1 for distance and the second one for labels in the hclust:
hclust(d, labels = TRUE)
Good luck with your task :)
Upvotes: 1