取
char *put_int(int nb)
{
char *str;
str = malloc(sizeof(char) * 4);
if (str == NULL)
return (0);
str[0] = (nb / 100) + '0';
str[1] = ((nb - ((nb / 100 * 100 )) / 10) + '0');
str[2] = ((nb % 10) + '0');
return (str);
}
void put_str(char *str)
{
while (*str)
write(1, str++,1);
}
int main(void)
{
put_str(put_int(42));
return (0);
}
返回
DT <- CJ(1:2, 2:3)
key.the.DT <- function(data.table, primary.key)
setkey(data.table, primary.key)
key.the.DT(data.table = DT, primary.key = 'V1')
如何从函数内部键入data.table?
修改 对于两个或更多键......
Error in setkeyv(x, cols, verbose = verbose, physical = physical) :
some columns are not in the data.table: primary.key
答案 0 :(得分:4)
我们可以在函数
中使用setkeyv
key.the.DT <- function(data.table, primary.key)
setkeyv(data.table, primary.key)
key.the.DT(data.table = DT, primary.key = 'V1')
key(DT)
#[1] "V1"