I have encountered this problem on several occasions and am not sure how to
handle it. I use for-loops to cycle through datasets. When each dataset is
of equal length, it works fine as I can combine the datasets and have each
loop pick up a different column, but when the datasets are differing
lengths, I am struggling. Here is an example:
A<-1:10
B<-1:15
C<-1:18

Set1<-data.frame(A,runif(10))
Set2<-data.frame(B,runif(15))
Set3<-data.frame(C,runif(18))

for (i in 1:3){
if (i==1) Data<-Set1 else if (i==2) Data<-Set2 else Data<-Set3
dev.new()
plot(Data[,1],Data[,2])
}


I don't always want to plot them and instead do other things, such as fit a
non-linear equation to the dataset, etc. I end up using that "if" statement
to cycle through the datasets and was hoping there is an easier method.
Maybe one would be to add extra zeros until they are the same length and
then take out the extra zeros in the first step. Any help would be
appreciated.

-----
In theory, practice and theory are the same. In practice, they are not - Albert 
Einstein
--
View this message in context: 
http://r.789695.n4.nabble.com/For-loop-to-cycle-through-datasets-of-differing-lengths-tp3987308p3987308.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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