Update to curves2d()

[This article was first published on geomorph, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.


Dear morphometricians,

Below you will find an update to our function for digitizing curves in 2d: curves2d(). This solves a problem with the function plotting landmarks and semilandmarks out of sequence. To use it, you can “source()” the code from a directory, or copy and paste it during digitizing.


Cheers,

Erik

CODE:

curves2d<-function(file, nsliders){
lm<-readland.nts(spec.name<-basename(file))
lm <- matrix(lm, ncol = dim(lm)[2], byrow=T)
spec.name<-unlist(strsplit(spec.name, "\\."))[1]
plot(lm[,1],lm[,2],cex=1,pch=21,bg=”white”)
text(lm[,1],lm[,2],label=paste(“LM”,1:dim(lm)[1]),adj=.5,pos=1)
selected<-matrix(NA,ncol=3,nrow=nsliders)
select<-NULL
for(i in 1:nsliders){
for(j in 1:3){
select<-identify(lm,n=1,plot=FALSE,cex=5,pch=25)
selected[i,j]<-select
if(j==2){
points(lm[select,][1],lm[select,][2],cex=1.5,pch=19,col=”red”)
arrows(lm[selected[i,j],][1],lm[selected[i,j],][2],lm[selected[i,j-1],][1],lm[selected[i,j-1],][2]
,col=”red”,lwd=2,length=.15)
} else {
points(lm[select,][1],lm[select,][2],cex=1.1,pch=19,col=”blue”)
}
if(j==3){
arrows(lm[selected[i,j],][1],lm[selected[i,j],][2],lm[selected[i,j-1],][1],lm[selected[i,j-1],][2]
,col=”red”,lwd=2,length=.15,code=1)
#lines(rbind(lm[selected[i,j],],lm[selected[i,j-1],]),col=”red”,lwd=2)
} else { NA
}
}
}
output<-selected
cat(paste(‘”sliders’,sep=””),file=paste(“sliders.nts”,sep=””),sep=”\n”)
cat(paste(1,dim(output)[1],3,0, “dim=3″),file=”sliders.nts”,sep=”\n”,append=TRUE)
write.table(output,file=”sliders.nts”,col.names = FALSE, row.names = FALSE,sep=” “,append=TRUE)
return(list(sliders=output))
}


To leave a comment for the author, please follow the link and comment on their blog: geomorph.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)