I am using if else and loop to sortout the data set that is the values less than o or more than 100 will be chosen.I could not get outTable with loop.
Please help me to correct the code:
I USED:

# Read
a_data <- read.table("D:/SNP/copy.sas", header=T, sep="\t")
tr <- a_data$truck
ca <- a_data$cars
length <- nrow(a_data)
outTable <- matrix(nrow=length,ncol=3)

stat <- for (i in 1:length) {
if (tr<0) {0} else
if (ca>100) {0}else
{ca}
outTable <- c(i, stat, tr)
}
# Writing the output file
  colnames(outTable) <- c("number", "stat", "tr")
write.table(outTable,"D:/SNP/mixed.txt",append=FALSE,quote=FALSE,sep='\t', row.names=F)
# Graph
plot(stat, type="o", col="red", axes=FALSE, ann=FALSE)
# Create a title with a red, bold/italic font title(main="Autos", col.main="red", font.main=4)
# Start PNG device driver to save output to figure.png
png(filename="D:/SNP/figure.png", height=295, width=300, bg="white")
.....................
COMPLAIN
Error: object 'stat' not found
In addition: Warning message:
In if (tr < 0) { :
  the condition has length > 1 and only the first element will be used
...................

Thank alot

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to