<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><p id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; margin: 0px; line-height: auto;">Sorry if this is a basic question.</p><p id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; margin: 0px; line-height: auto;"><br></p><p id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; margin: 0px; line-height: auto;"><span style="font-family: sans-serif; line-height: normal; ">I'm using R 3.0.0 and data.table 1.8.8.</span><span style="font-family: sans-serif; line-height: normal; "> </span>The documentation for 'j' states that "<span style="font-family: sans-serif; line-height: normal; ">A single column or single expression returns that type, usually a vector."</span></p><p id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; margin: 0px; line-height: auto;"><span style="font-family: sans-serif; line-height: normal; "><br></span></p><p id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; margin: 0px; line-height: auto;"><span style="font-family: sans-serif; line-height: normal; ">I am able to obtain this behavior if I know the column name in advance:</span></p><p id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; margin: 0px; line-height: auto;"><span style="font-family: sans-serif; line-height: normal; "><br></span></p><p id="bloop_customfont" style="margin: 0px; "><p id="bloop_customfont" style="margin: 0px; "><font face="Courier New">> dt = data.table(a=c(1, 2, 3), b=c(4, 5, 6))</font></p><p id="bloop_customfont" style="margin: 0px; "><font face="Courier New">> dt</font></p><p id="bloop_customfont" style="margin: 0px; "><font face="Courier New">   a b</font></p><p id="bloop_customfont" style="margin: 0px; "><font face="Courier New">1: 1 4</font></p><p id="bloop_customfont" style="margin: 0px; "><font face="Courier New">2: 2 5</font></p><p id="bloop_customfont" style="margin: 0px; "><font face="Courier New">3: 3 6</font></p><p id="bloop_customfont" style="margin: 0px; "><font face="Courier New">> str(dt[,a])</font></p><p id="bloop_customfont" style="margin: 0px; "><font face="Courier New"> num [1:3] 1 2 3</font></p></p><div><div class="bloop_container"><div class="bloop_frame">  </div></div></div><div><br></div><div>However, if I don't, no such luck:</div><div><br></div><div><div><font face="Courier New">> colname="a"</font></div><div><font face="Courier New">> str(dt[,colname,with=F])</font></div><div><font face="Courier New">Classes ‘data.table’ and 'data.frame':<span class="Apple-tab-span" style="white-space:pre">       </span>3 obs. of  1 variable:</font></div><div><font face="Courier New"> $ a: num  1 2 3</font></div><div><font face="Courier New"> - attr(*, ".internal.selfref")=<externalptr> </font></div></div><div><br></div><div>If there a way to extract an entire column as a vector if I have the column name as a character scalar?</div><div><br></div><div>Thank you!</div><div><br></div><div id="bloop_sign_1368801224531704832"><span style="font-family:helvetica,arial;font-size:13px"></span><div style="font-family: Helvetica; line-height: normal; ">-- </div><div style="font-family: Helvetica; line-height: normal; "><span style="font-family: arial; font-size: small; ">Alexandre Sieira</span><br style="font-family: arial; font-size: small; "><span style="font-family: arial; font-size: small; ">CISA, CISSP, ISO 27001 Lead Auditor</span><br style="font-family: arial; font-size: small; "><br style="font-family: arial; font-size: small; "><span style="font-family: arial; font-size: small; ">"The truth is rarely pure and never simple."</span><br style="font-family: arial; font-size: small; "><span style="font-family: arial; font-size: small; ">Oscar Wilde, The Importance of Being Earnest, 1895, Act I</span></div></div></body></html>