Use \tcp*[f]
rather than \tcp*[r]
. According to the algorithm2e
documentation (section 10.3 comments, p 31):
\tcp*[r]
right justified side comment, ends the line (default)
\tcp*[f]
right justified comment, without end line; useful with "if-then-else" macros for example
\documentclass{article}
\usepackage{algorithm2e}% http://ctan.org/pkg/algorithm2e
\newcommand{\variable}{\textup}
\newcommand{\func}{\textsf}
\begin{document}
\begin{algorithm}
\For(\tcp*[r]{Incremental calculation of edges}){$i \gets 1$ \textbf{\upshape{to}} $n$}{
\If {$i=1$}
{
$currentCenter \gets MEAN(x_{R'[2]},\ldots,x_{R'[k_{min}+1]})$\;
$currentSSE \gets SSE(x_{R'[2]},\ldots,x_{R'[k_{min}+1]})$\;
}}
\For(\tcp*[f]{Incremental calculation of edges}){$i \gets 1$ \textbf{\upshape{to}} $n$}{
\If {$i=1$}
{
$\variable{currentCenter} \gets \func{MEAN}(x_{R'[2]},\ldots,x_{R'[k_{\min}+1]})$\;
$\variable{currentSSE} \gets \func{SSE}(x_{R'[2]},\ldots,x_{R'[k_{\min}+1]})$\;
}}
\end{algorithm}
\end{document}
I've added some other formatting as well, since it seems needed.
\documentclass
and ending with\end{document}
there is not enough context in your question to give a definitive answer. please also identify what version ofalgorithm2e
is being used -- a recent instance of a very similar situation required code changes because an older version of the package was being used (the current version is 5.0 2013/01/06); it was possible to determine the needed changes from the package documentation.