0

I'm using R for coding. I need to add/update an optional field in my protobuffer files. The function "add" works well for repeated fields; but it does not seem to be compatible for optional fields.

example:

A$add("gender", X["gender"]); # Works if A is repeated; but not when it's optional!

Do you know what function I should use for this purpose?

Thanks

Charles Caldwell
  • 16,649
  • 4
  • 40
  • 47
  • Welcome to Stack Overflow. When posting a question, it's helpful to include a [minimal, reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) showing exactly how you created your objects, and the behavior your expect. Be sure to explicitly list all non-standard libraries needed to run the sample code. – MrFlick Jun 11 '14 at 22:34

3 Answers3

1

try the following

A$set("gender", X["gender"]);
1

I found the solution!

If "add" does not work, you should try:

A$gender = X["gender"];

Should work! Thanks

0

The optional field already exists. You only need to assign a value to it.

erbridge
  • 1,376
  • 12
  • 27