loc <> x <> y <> plot(x, y, type="n", xlab="", ylab="", main="cmdscale(eurodist)") text(x, y, rownames(loc), cex=0.8) >>>This uses a pre-loaded dataset called eurodist which has European city distances. The first command stores the output from cmdscale in the object 'loc'. The output is a set of points in (by default) 2-d space. The next two commands put the first and second columns of 'loc' into their own variables (flipping the sign of y) and then the last two plot and label them, with some extra options to make the graph look nicer. That's the whole process.
source("http://personality-project.org/r/useful.r") #get some extra functions, including read.clipboard()
cities <> cities #show the data
city.location <> round(city.location,0) #print the locations to the screen
plot(city.location,type="n", xlab="Dimension 1", ylab="Dimension 2",main ="cmdscale(cities)") #put up a graphics window
text(city.location,labels=names(cities)) #put the cities into the map
>>
"Error in read.table(file("clipboard"), header = TRUE, ...) :I tried tweaking the mileage distance chart in a variety of ways (adding & removing columns, adding & removing column names, etc.), but R was stubborn. So I switched to read.table, which I found to be a much better solution for my purposes in any event.
more columns than column names
You are not logged in, either login or create an account to post comments
Not your problem exactly, but check out this map of France "derived from inadequate data".
posted by Rumple at 7:08 PM on October 29 [2 favorites has favorites]