r - Data Table Column Reference -


i have data table column names strings of characters.

while

datatable[rownumber, `column name`] 

is working fine,

datatable[rownumber,datatable2[rownumber,,columnname]] 

is not working.

datatable2[rownumber,,columnname2]= column name2 

how fix this?

you might running problem needing set "with = false" if referencing column name text string , not is.

example

library(data.table)  head(iris)  > head(iris)   sepal.length sepal.width petal.length petal.width species 1          5.1         3.5          1.4         0.2  setosa 2          4.9         3.0          1.4         0.2  setosa  # data.frame convert data.table dt <- as.data.table(iris)  dt[1, sepal.length] # 5.1      dt[1, "sepal.length"] # gives error, need with!  dt[1, "sepal.length", = false] # 5.1   # done when code columns programmatically my.col <- "sepal.length" dt[1, my.col, = false] # 5.1  

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -