Loss of attributes despite attempts to preserve them

僤鯓⒐⒋嵵緔 提交于 2019-12-04 11:37:32

I'm answering my own question - well, for now, only partially:

1) Under more intense investigation and after some code updates, it appears that attributes in fact are NOT being lost (still trying to figure out what changes caused the expected behavior - will report later).

2) I have figured out the reason of intermittent output and losing all cache data after the transformation, as follows. During multiple subsequent runs of the code, the second run of each transformation (handler) function (projectAge(), projectLicense() and devTeamSize()) returns NULL, since the transformation has already been done:

if (<condition>) {
  ...
  message("Not processing - Transformation already performed!\n")
  return (invisible()) # <= returns NULL
}

The returned NULL then was getting passed to saveRDS(), thus, causing the loss of cache data.

I fixed this problem by simple validation of result before saving the transformed object:

# the next line is problematic due to wrong assumption of always having full data returned
result <- do.call(handler, list(indicator, data2))
if (!is.null(result)) saveRDS(result, rdataFile) # <= fixed by validating incoming data

That's it so far, thanks for reading! I will be updating this answer until all the issues are clarified.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!