在R中绘制棋盘。如何命名列和行?

我编写了绘制棋盘的函数。我想用字母命名每个列和行。但是,我不知道该怎么做。

我的代码:

library(tidyverse)

dt = read.table(text = "
Group   Vol  OI   CumVol Rd   
  2008-08-10  0     0      0       0      
  2008-08-10  100   100    100     1
  2008-08-10  0     100    300     1
  2008-08-10  0     100    400     1     
  2008-08-10  50    150    550    0.27
  2009-12-10  0     150     0      0 
  2009-12-10  50    30    50      0.6
  2009-12-10  0     20     50     0.6
",header=T)

dt %>%
  group_by(Group) %>%
  mutate(Rd1 = ifelse(Vol==0,NA,OI/CumVol),# calculate 
         Rd1 = ifelse(row_number() == 1,Rd1)) %>%  # replace NAs with 0 in 1st rows only
  fill(Rd1) %>%                                        # get the previous non NA value
  ungroup()

# # A tibble: 8 x 6
#   Group        Vol    OI CumVol    Rd   Rd1
#   <fct>      <int> <int>  <int> <dbl> <dbl>
# 1 2008-08-10     0     0      0  0    0    
# 2 2008-08-10   100   100    100  1    1    
# 3 2008-08-10     0   100    300  1    1    
# 4 2008-08-10     0   100    400  1    1    
# 5 2008-08-10    50   150    550  0.27 0.273
# 6 2009-12-10     0   150      0  0    0    
# 7 2009-12-10    50    30     50  0.6  0.6  
# 8 2009-12-10     0    20     50  0.6  0.6 

现在我有:

在R中绘制棋盘。如何命名列和行?

但是,我想要拥有:

在R中绘制棋盘。如何命名列和行?

true429 回答:在R中绘制棋盘。如何命名列和行?

我对国际象棋了解不多,但这可能很接近:

 import { searchFilter } from '../components/app';
 export function reducer (state = {},action) {

    switch (action.type) {
      case 'SET_SHIFT':
         return Object.assign({},state,{
            shift: action.shift
         });
      case 'SET_SEARCH':
         return Object.assign({},{
            search: action.search.toLowerCase()
         });
      case 'RUN_FILTER':
         return Object.assign({},{
            shift: action.shift || state.shift,search: action.search || state.search,filteredData: searchFilter(state.search,state.data[state.shift])
         });
      case 'LOAD_DATA_START':
         return Object.assign({},{
            day: action.day
         });
      case 'LOAD_DATA_END':
         return Object.assign({},{
            data: action.data,shift: Object.keys(action.data)[0],state.data[state.shift])
         });
      default:
         return state;
   }
}

本文链接:https://www.f2er.com/3136752.html

大家都在问