R if then else loop -


i have following output , insert column if net.results$net output equal 0 if output if <0.5 , 1 if >0.5 <1.0. rounding or down.

how go doing in in loop ? can insert column using data.frame below , in between predicted , test set columns ?

assume don't know number of rows net.results$net.result has.

thank help.

data.frame(net.results$net.result,diabtest$class)

           predicted col            test set col  net.results.net.result diabtest.class 4             0.2900909633              0 7             0.2900909633              1 10            0.4912509122              1 12            0.4912509122              1 19            0.2900909633              0 21            0.2900909633              0 23            0.4912509122              1 26            0.2900909633              1 27            0.4912509122              1 33            0.2900909633              0 

as commenters have pointed out. not work situations, based on appearance of data, should produce output desired.

df$rounded <- round(df$net.results.net.result,0) 

here few test values see function different numbers. read round page more info.

round(0.2900909633,0) [1] 0 round(0.51, 0) [1] 1 

you can supplying reproducible example, doing research, , explaining approaches you've tried.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -