This is a super newbie question, but I'm completely lost in the documentation. I have a CSV that can be user_id and score type (a data value that can be for "TP", "FP", or "positive", positive, false positive, respectively, for the wrong negative).
My data looks like this:
user_id, type, value 1 tp 342 1 fp 22 1 fn 25 2 tp 232 2 fp 342 2 fn 3 etc.
I want to calculate F1 points from this data. I have written a function that takes TP, FP, and FN as logic, but first I need to rearrange this table so that the type of score becomes a column:
< Code> user_id, tp, fp, fn1 342 22 25 etc Can anyone tell me in the right direction?
Thank you!
Here you can go:
Library (reshape2) dcast (Dat, user_id ~ type, fun.aggregate = sum, value) var = 'value') user_id fn fp tp 1 1 25 22 342 2 2 3 342 232 I should say, I think that it assumes that only one value will be for each user (otherwise sum will not be the right option) for each variable
No comments:
Post a Comment