[R] Adding column values based on a condition

Alessandro Puglisi @|e@@@ndro@pug||@| @end|ng |rom gm@||@com
Sat Jul 6 11:55:30 CEST 2019


Hi all!

I have a tibble regarding a series of comments on a forum; the tibble has a
certain number of variables, and in particular:

id: comment id;
author_id: author id;
parent_id: if the message is a reply, the original comment id

I want to add another column, in which I put the author id of the original
comment, when parent_id IS NOT NA.

I already tried to use mutate + ifelse but my problem is that I have to
refer to an author id in a different row than that in which I'm evaluating
the if condition...

Thanks in advance,
Alessandro

	[[alternative HTML version deleted]]



More information about the R-help mailing list