# Modified from ### rm(list=ls(all=TRUE)) # Remove all objects just to be safe ## TO DO LIST FOR THE LINGUIST.############################### ### <1> $$ ENTER file path to folder where textfile is located, and where output Files will be stored # Directory_Name <- '/home/jtimm/Desktop/jt_OC/' Directory_Name <- 'C:\\Users\\jtimm\\Desktop' ### <2> $$ ENTER the name of the data file # DATA <- 'Attrib3-13transpose.txt' DATA <- 'Exclamatives.txt' # X and Z files do not have to be entered; it is assumed their file names have been produced by Main Script ### <3> $$ Enter the column range of cutting line subset you would like to plot. # Do not include the column with row names in this count. #sub_Range <- c(1:12) sub_Range <- c(1:9) ### <4> $$ Select ALL TEXT in this file (including that which precedes), and RUN Script. ############################## setwd(Directory_Name) title <- gsub('.txt', "", DATA) z_Data <- paste (title,'2D_Z_File.txt', sep = "_") x_Data <- paste (title,'2D_X_File.txt', sep = "_") dat <- read.delim(DATA, header = TRUE) zz <- read.delim(file = z_Data, header = TRUE) xx <- read.delim(file = x_Data, header = TRUE) names2 <- colnames(dat) zz <- zz[,-1] xx <- xx[,-1] fromHR <- dat[,-1] names2 <- colnames(fromHR) #result999 <- ifelse(is.na(zz),999,zz) zz[is.na(zz)] <- 999 result999 <- zz nvotescaled <- sum(result999[,7]!=999) # # ws <- zz[,8] N1 <- zz[,6] N2 <- zz[,7] # oc1 <- xx[,7] oc2 <- xx[,8] xlarrow <- 0.1 #Subset Plot; jpeg(paste (title,'SUB', min(sub_Range), max(sub_Range),'CuttingLines.jpeg',sep = "_"),width = 7, height = 7, units = 'in',res = 300) plot(N1,N2,type="n",asp=1, main="", xlab="", ylab="", xlim=c(-1.0,1.0),ylim=c(-1.0,1.0),cex=1.2,font=2) for (i in sub_Range){ if(result999[i,7]!=999){ xws <- ws[i]*N1[i] yws <- ws[i]*N2[i] arrows(xws,yws,xws+N2[i],yws-N1[i],length=0.0,lwd=2,col="black") arrows(xws,yws,xws-N2[i],yws+N1[i],length=0.0,lwd=2,col="black") polarity <- oc1*N1[i] + oc2*N2[i] - ws[i] vote <- fromHR[,i] ivote <- as.integer(vote) errors1 <- ivote==1 & polarity >= 0 errors2 <- ivote==6 & polarity <= 0 errors3 <- ivote==1 & polarity <= 0 errors4 <- ivote==6 & polarity >= 0 kerrors1 <- ifelse(is.na(errors1),9,errors1) kerrors2 <- ifelse(is.na(errors2),9,errors2) kerrors3 <- ifelse(is.na(errors3),9,errors3) kerrors4 <- ifelse(is.na(errors4),9,errors4) kerrors12 <- sum(kerrors1==1)+sum(kerrors2==1) kerrors34 <- sum(kerrors3==1)+sum(kerrors4==1) if(kerrors12 < kerrors34){ xwslow <- (ws[i]- xlarrow)*N1[i] ywslow <- (ws[i]- xlarrow)*N2[i] } if(kerrors12 >= kerrors34){ xwslow <- (ws[i]+ xlarrow)*N1[i] ywslow <- (ws[i]+ xlarrow)*N2[i] } arrows(xws+N2[i],yws-N1[i],xwslow+N2[i],ywslow-N1[i],length=0.1,lwd=2,col="red") arrows(xws-N2[i],yws+N1[i],xwslow-N2[i],ywslow+N1[i],length=0.1,lwd=2,col="red") } i <- i + 1 } points(oc1,oc2,pch=16,col="red",font=2) for (i in sub_Range){ text(ws[i]*N1[i]+N2[i],ws[i]*N2[i]-N1[i],names2[i],pos=2,offset=00.20,col="blue") text(ws[i]*N1[i]-N2[i],ws[i]*N2[i]+N1[i],names2[i],pos=2,offset=00.20,col="blue") } dev.off()