根据条件替换数据框中的列值

时间:2014-10-23 10:00:57

标签: r dataframe conditional

我的数据框有两列Drivers_90_00_Visual"Drivers_00_05_Visual

dput(list_table_Tanzania_Merge2)
structure(list(Drivers_90_00_Visual = c(100L, 100L, 100L, 100L, 
100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 520L, 
520L, 100L, 100L, 200L, 520L, 200L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 530L, 520L, 520L, 0L, 0L, 
0L, 0L, 100L, 100L, 100L, 100L, 0L, 200L, 200L, 520L, 520L, 520L, 
520L, 100L, 100L, 100L, 520L, 520L, 520L, 520L, 520L, 520L, 100L, 
520L, 520L, 520L, 520L, 520L, 100L, 520L, 100L, 100L, 520L, 100L, 
100L, 100L, 100L, 100L, 100L, 0L, 0L, 100L, 0L, 0L, 0L, 100L, 
520L, 520L, 520L, 100L, 520L, 200L, 100L, 520L, 520L, 520L, 100L, 
0L, 0L, 520L, 520L, 100L, 520L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
200L, 100L, 520L, 200L, 100L, 520L, 200L, 200L, 100L, 100L, 200L, 
100L, 200L, 100L, 200L, 200L, 520L, 200L, 200L, 200L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 100L, 520L, 100L, 520L, 
520L, 200L, 200L, 100L, 200L, 200L, 100L, 520L, 520L, 100L, 520L, 
100L, 520L, 100L, 520L, 520L, 100L, 200L, 520L, 100L, 100L, 200L, 
200L, 100L, 100L, 100L, 200L, 100L, 200L, 200L, 200L, 200L, 200L, 
520L, 520L, 100L, 520L, 200L, 520L, 520L, 520L, 200L, 200L, 520L, 
520L, 100L, 100L, 100L, 200L, 100L, 200L, 100L, 200L, 200L, 100L, 
200L, 100L, 200L, 200L, 100L, 200L, 100L, 520L, 200L, 520L, 200L, 
200L, 100L, 520L, 200L, 200L, 100L, 200L, 200L, 100L, 200L, 100L, 
100L, 200L, 100L, 200L, 200L, 200L, 100L, 200L, 200L, 200L, 100L, 
200L, 200L, 100L, 100L, 200L, 100L, 200L, 200L, 200L, 100L, 200L, 
200L, 200L, 100L, 200L, 200L, 100L, 200L, 100L, 200L, 200L, 100L, 
200L, 200L, 100L, 100L, 200L, 200L, 200L, 100L, 100L, 200L, 200L, 
200L, 200L, 100L, 200L, 100L, 100L, 100L, 100L, 200L, 100L, 200L, 
200L, 0L, 100L, 520L, 520L, 200L, 100L, 100L, 100L, 200L, 100L, 
100L, 200L, 200L, 0L, 100L, 200L, 520L, 200L, 100L, 100L, 200L, 
100L, 100L, 100L, 100L, 200L, 100L, 200L, 200L, 200L, 200L, 100L, 
200L, 100L, 100L, 100L, 0L, 200L, 0L, 0L, 200L, 0L, 0L, 100L, 
0L, 100L, 0L, 200L, 0L, 0L, 100L, 200L, 200L, 200L, 200L, 100L, 
200L, 200L, 0L, 100L, 100L, 0L, 200L, 0L, 200L, 200L, 200L, 0L, 
100L, 100L, 200L, 520L, 520L, 100L, 520L, 520L, 200L, 100L, 0L, 
100L, 100L, 100L, 520L, 100L, 100L, 0L, 0L, 0L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 520L, 200L, 520L, 520L, 200L, 
200L, 520L, 200L, 200L, 200L, 200L, 200L, 200L, 240L, 240L, 200L, 
200L, 200L, 200L, 520L, 520L, 520L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 240L, 200L, 200L, 200L, 100L, 240L, 200L, 100L, 240L, 
200L, 100L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
100L, 200L, 200L, 200L, 200L, 200L, 200L, 100L, 200L, 200L, 200L, 
200L, 200L, 100L, 100L, 200L, 240L, 200L, 200L, 200L, 200L, 520L, 
200L, 200L, 100L, 520L, 200L, 200L, 100L, 520L, 520L, 200L, 200L, 
240L, 100L, 520L, 100L, 200L, 520L, 200L, 200L, 240L, 100L, 240L, 
520L, 200L, 240L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 100L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 100L, 520L, 200L, 200L, 200L, 200L, 
520L, 200L, 100L, 200L, 520L, 520L, 200L, 200L, 200L, 200L, 200L, 
100L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 520L, 200L, 200L, 
520L, 520L, 200L, 200L, 200L, 520L, 200L, 200L, 200L, 200L, 100L, 
200L, 100L, 200L, 200L, 100L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
100L, 100L, 100L, 200L, 200L, 200L, 200L, 200L, 100L, 200L, 200L, 
100L, 100L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 100L, 100L, 100L, 200L, 100L, 200L, 200L, 
200L, 100L, 200L, 100L, 200L, 100L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 100L, 200L, 100L, 200L, 100L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 100L, 200L, 100L, 200L, 200L, 520L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 100L, 200L, 200L, 200L, 
200L, 200L, 100L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 200L, 200L, 100L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 100L, 100L, 100L, 
100L, 200L, 200L, 200L, 100L, 100L, 200L, 200L, 100L, 200L, 200L, 
200L, 200L, 520L, 200L, 200L, 200L, 100L, 200L, 200L, 520L, 200L, 
200L, 200L, 200L, 520L, 520L, 520L, 520L, 200L, 520L, 200L, 200L, 
200L, 200L, 520L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 
200L, 200L, 200L, 520L, 200L, 520L, 520L, 520L, 200L, 200L, 200L, 
200L, 200L, 200L, 520L, 200L, 200L, 200L, 200L, 520L, 200L, 520L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 100L, 100L, 100L, 200L, 
200L, 100L, 100L, 100L, 100L, 200L, 200L, 200L, 200L, 100L, 200L, 
100L, 200L, 100L, 100L, 200L, 100L, 200L, 200L, 100L, 200L, 200L, 
200L, 200L, 100L, 100L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 200L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 200L, 200L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
200L, 200L, 100L, 200L, 100L, 100L, 520L, 520L, 520L, 520L, 520L, 
520L, 200L, 200L, 200L, 100L, 100L, 200L, 200L, 0L, 100L, 100L, 
200L, 200L, 520L, 100L, 100L, 100L, 200L, 100L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 100L, 100L, 200L, 200L, 200L, 200L, 200L, 
100L, 200L, 200L, 200L, 200L, 100L, 520L, 100L, 200L, 520L, 200L, 
200L, 200L, 100L, 100L, 520L, 200L, 200L, 200L, 200L, 200L, 200L, 
100L, 200L, 200L, 200L, 520L, 100L, 520L, 100L, 100L, 100L, 200L, 
200L, 520L, 100L, 200L, 200L, 200L, 200L, 200L, 100L, 200L, 100L, 
200L, 200L, 100L, 200L, 200L, 100L, 200L, 520L, 200L, 200L, 200L, 
520L, 200L, 200L, 200L, 200L, 200L, 520L, 100L, 100L, 100L, 200L, 
200L, 200L, 200L, 100L, 100L, 520L, 100L, 100L, 200L, 200L, 200L, 
200L, 200L, 100L, 200L, 200L, 200L, 200L, 520L, 100L, 240L, 200L, 
520L, 520L, 200L, 520L, 520L, 200L, 100L, 200L, 100L, 100L, 100L, 
100L, 200L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 
100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 
100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 
200L, 100L, 100L, 100L, 100L, 100L, 200L, 100L, 100L, 100L, 100L, 
200L, 200L, 100L, 520L, 200L, 520L, 100L, 200L, 100L, 100L, 100L, 
520L, 200L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 200L, 100L, 
100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 520L, 100L, 100L, 
100L, 520L, 520L, 100L, 100L, 100L, 200L, 100L, 100L, 100L, 100L, 
100L, 100L, 100L, 100L, 200L, 100L, 200L, 100L, 200L, 100L, 100L, 
200L, 520L, 200L, 520L, 520L, 200L, 200L, 520L, 100L, 100L, 100L, 
100L, 520L, 520L, 520L, 520L, 100L, 200L, 200L, 200L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 100L, 
520L, 520L, 520L, 520L, 200L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 200L, 520L, 520L, 520L, 520L, 520L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 100L, 200L, 520L, 
520L, 999L, 520L, 999L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 999L, 520L, 520L, 
0L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 520L, 520L, 100L, 100L, 520L, 600L, 600L, 600L, 100L, 520L, 
520L, 100L, 100L, 100L, 100L, 520L, 100L, 200L, 200L, 100L, 100L, 
100L, 100L, 520L, 100L, 200L, 200L, 200L, 100L, 100L, 520L, 100L, 
200L, 100L, 100L, 100L, 100L, 200L, 200L, 520L, 100L, 100L, 100L, 
0L, 0L, 200L, 520L, 200L, 520L, 520L, 100L, 520L, 200L, 100L, 
100L, 100L, 100L, 100L, 100L, 520L, 520L, 100L, 100L, 100L, 100L, 
100L, 100L, 100L, 100L, 520L, 520L, 100L, 100L, 100L, 100L, 100L, 
100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 
100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 
100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 
100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 
100L, 100L, 100L, 100L, 520L, 520L, 520L, 520L, 520L, 200L, 520L, 
520L, 520L, 520L, 520L, 100L, 520L, 100L, 100L, 100L, 100L, 100L, 
100L, 520L, 200L, 100L, 100L, 100L, 100L, 100L, 100L, 520L, 520L, 
520L, 520L, 520L, 520L, 100L, 520L, 100L, 100L, 100L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 100L, 
100L, 100L, 100L, 520L, 520L, 520L, 520L, 520L, 100L, 100L, 100L, 
520L, 520L, 520L, 100L, 520L, 520L, 100L, 100L, 520L, 520L, 520L, 
520L, 520L, 100L, 100L, 100L, 0L, 0L, 100L, 100L, 100L, 100L, 
100L, 100L, 100L, 0L, 100L, 100L, 520L, 520L, 520L, 520L, 520L, 
200L, 200L, 200L, 520L, 200L, 200L, 520L, 520L, 200L, 100L, 100L, 
200L, 100L, 200L, 200L, 200L, 200L, 200L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 200L, 200L, 200L, 200L, 200L, 
520L, 200L, 200L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 200L, 
200L, 520L, 520L, 520L, 100L, 520L, 100L, 520L, 520L, 100L, 520L, 
100L, 520L, 100L, 100L, 520L, 100L, 100L, 100L, 100L, 100L, 100L, 
100L, 100L, 100L, 100L, 100L, 100L, 100L), Drivers_00_05_Visual = c(520L, 
200L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 200L, 200L, 200L, 520L, 520L, 200L, 520L, 200L, 200L, 200L, 
520L, 520L, 200L, 520L, 520L, 520L, 520L, 520L, 520L, 530L, 520L, 
520L, 0L, 0L, 0L, 0L, 520L, 520L, 520L, 520L, 0L, 200L, 200L, 
520L, 520L, 520L, 520L, 200L, 200L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 200L, 200L, 520L, 520L, 200L, 520L, 
520L, 200L, 520L, 520L, 520L, 520L, 520L, 520L, 0L, 0L, 520L, 
0L, 0L, 0L, 520L, 520L, 520L, 520L, 520L, 520L, 200L, 520L, 200L, 
520L, 520L, 520L, 0L, 0L, 520L, 520L, 520L, 520L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 520L, 200L, 200L, 200L, 200L, 200L, 
200L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 520L, 200L, 520L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 520L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 520L, 
200L, 200L, 520L, 200L, 520L, 520L, 520L, 200L, 520L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 200L, 520L, 520L, 
520L, 200L, 200L, 520L, 520L, 200L, 200L, 200L, 520L, 200L, 200L, 
200L, 520L, 520L, 200L, 200L, 200L, 200L, 520L, 200L, 520L, 200L, 
200L, 200L, 520L, 200L, 200L, 200L, 520L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 520L, 200L, 200L, 200L, 520L, 
520L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 520L, 200L, 
200L, 200L, 200L, 200L, 0L, 520L, 520L, 520L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 0L, 200L, 200L, 520L, 200L, 
520L, 520L, 200L, 520L, 520L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 0L, 200L, 0L, 0L, 200L, 
0L, 0L, 200L, 0L, 200L, 0L, 200L, 0L, 0L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 0L, 200L, 200L, 0L, 200L, 0L, 200L, 200L, 
200L, 0L, 200L, 200L, 200L, 520L, 520L, 200L, 520L, 520L, 200L, 
200L, 0L, 200L, 200L, 200L, 520L, 520L, 520L, 0L, 0L, 0L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 240L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 520L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 520L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 520L, 520L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 520L, 520L, 200L, 200L, 200L, 520L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 240L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 520L, 200L, 200L, 200L, 200L, 200L, 240L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 240L, 
200L, 200L, 240L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 240L, 200L, 200L, 200L, 520L, 200L, 200L, 520L, 520L, 
520L, 200L, 200L, 200L, 240L, 240L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 520L, 520L, 200L, 500L, 520L, 
200L, 500L, 200L, 240L, 520L, 240L, 200L, 240L, 240L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 520L, 200L, 200L, 520L, 200L, 200L, 
520L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
520L, 520L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
200L, 200L, 200L, 200L, 520L, 240L, 600L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 520L, 520L, 520L, 520L, 200L, 
200L, 200L, 520L, 520L, 520L, 520L, 520L, 520L, 200L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 200L, 200L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 200L, 200L, 530L, 200L, 200L, 200L, 520L, 520L, 520L, 
520L, 520L, 520L, 200L, 200L, 240L, 520L, 200L, 200L, 200L, 0L, 
520L, 200L, 200L, 240L, 200L, 200L, 240L, 240L, 200L, 520L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 240L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 240L, 240L, 240L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 240L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 240L, 
240L, 200L, 520L, 520L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 240L, 200L, 200L, 240L, 240L, 240L, 240L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 500L, 500L, 500L, 500L, 500L, 200L, 200L, 
200L, 200L, 500L, 500L, 520L, 200L, 200L, 520L, 200L, 200L, 200L, 
200L, 200L, 500L, 500L, 200L, 520L, 200L, 240L, 240L, 500L, 200L, 
200L, 240L, 240L, 500L, 200L, 240L, 500L, 500L, 240L, 240L, 240L, 
520L, 240L, 240L, 200L, 240L, 240L, 240L, 200L, 200L, 200L, 240L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 240L, 200L, 240L, 240L, 
240L, 240L, 200L, 200L, 200L, 240L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 520L, 520L, 520L, 520L, 520L, 200L, 200L, 200L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 500L, 520L, 520L, 200L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 200L, 520L, 520L, 520L, 
520L, 520L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 520L, 520L, 200L, 520L, 200L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 200L, 
520L, 520L, 0L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 520L, 520L, 520L, 520L, 520L, 600L, 600L, 600L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 
200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 200L, 520L, 200L, 
200L, 200L, 0L, 0L, 200L, 200L, 200L, 520L, 520L, 520L, 520L, 
200L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
200L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 200L, 200L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 
530L, 520L, 520L, 520L, 520L, 520L, 520L, 0L, 0L, 520L, 520L, 
520L, 520L, 520L, 520L, 520L, 0L, 520L, 520L, 520L, 520L, 520L, 
520L, 520L, 200L, 200L, 200L, 520L, 200L, 200L, 520L, 520L, 200L, 
520L, 520L, 200L, 520L, 200L, 200L, 200L, 200L, 200L, 520L, 520L, 
520L, 520L, 200L, 200L, 200L, 200L, 200L, 200L, 240L, 200L, 520L, 
240L, 200L, 200L, 200L, 200L, 240L, 240L, 200L, 200L, 200L, 200L, 
200L, 200L, 520L, 200L, 200L, 200L, 520L, 240L, 240L, 240L, 240L, 
520L, 200L, 200L, 200L, 200L, 200L, 520L, 200L, 200L, 200L, 200L, 
200L, 200L, 520L, 520L, 520L, 200L, 520L, 520L, 200L, 200L, 520L, 
520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L, 520L)), .Names = c("Drivers_90_00_Visual", 
"Drivers_00_05_Visual"), class = "data.frame", row.names = c(NA, 
-1601L))

我想根据两个条件重新分类列的某些值。如果值= 250,230,240,210或220,它将获得值200,如果值= 520或530,则将获得值500.

1 个答案:

答案 0 :(得分:0)

你可以这样做:

  list_table_Tanzania_Merge2[] <- lapply(list_table_Tanzania_Merge2, 
                                  function(x) ifelse(x %in% c(250,230,240,210,220), 200,
                                           ifelse(x %in% c(520,530), 500, x)))


  str(list_table_Tanzania_Merge2)
  #'data.frame':    1601 obs. of  2 variables:
  #$ Drivers_90_00_Visual: num  100 100 100 100 100 100 100 100 100 100 ...
  #$ Drivers_00_05_Visual: num  500 200 500 500 500 500 500 500 500 500 ...