How to reference column names that start with a number, in data.table

前端 未结 2 2074
余生分开走
余生分开走 2020-12-17 23:30

If the column names in data.table are in the form of number + character, for example: 4PCS, 5Y etc, how could this be ref

2条回答
  •  失恋的感觉
    2020-12-18 00:02

    You can also put an 'X' immediately before the variable name you are calling to get R to recognise it as a name rather than evaluating the number and the string as different (and hence bad syntax)

    So e.g. when calling 4PCS use X4PCS

    as in

    mydata <- X4PCS

提交回复
热议问题