>
> On similar lines, how do I assign the position of the an occurence of a
> value say 7 in a data vector to another data vector?
>
> > nFields
> [1] 6 6 6 6 6 6 7 7 6 6 6 7 6 6 6 6
> I need the output data vector showing occurence of 7 as:
> [1] 7 8 12
which(nFields==7)
Regards
Petr
>
> I tried following but both has errors
> xFields7 <- NULL
> for (i in 1:length(nFields)) {
> c(xFields7,ifelse(nFields[i] == 7,i,NULL)) -> xFields7
> }
>
> xFields7 <- NULL
> for (i in 1:length(nFields)) {
> if nFields[i] == 7 then c(xFields7,i) -> xFields7
> }
>
>
______________________________________________
[email protected] 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.