Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8964165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:31:31+00:00 2026-06-15T16:31:31+00:00

I have a data.table my.data.table and a character vector i (length one) corresponding a

  • 0

I have a data.table my.data.table and a character vector i (length one) corresponding a to a colname of my.data.table. Using i, I would like to extract the corresponding column of my.data.table as a vector that is not of class data.table or data.frame.

How would I do this?

> my.data.table <- data.table(a=1:2,b=2:3)
> i <- "a"
> class(my.data.table[,i,with=FALSE])
[1] "data.table" "data.frame"
> as.vector(my.data.table[,i,with=FALSE])  ##does not work
   a
1: 1
2: 2
> is.vector(as.vector(my.data.table[,i,with=FALSE])) ##strange behavior
[1] FALSE
> 

I assume there’s a way to do this using with=FALSE and eval(i, <env>) in j but I can’t figure it out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:31:32+00:00Added an answer on June 15, 2026 at 4:31 pm

    Either one of these will work in your example, but the second of the two is more generally useful.

    my.data.table[[i]]
    # [1] 1 2
    my.data.table[,..i][[1L]]
    # [1] 1 2
    

    .. in data.table means to “look up one level” (in this case for the variable i)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in which one column (type ntext) has data that includes
I have a data.table X that I would like to create a variable based
I have data table containing one column as FilePath. FilePath D:\New folder\link.txt D:\New folder\SharepointMigration(Work
I have a data.table object like this one library(data.table) a <- structure(list(PERMNO = c(10006L,
I have a problem using data.table: How do I convert column classes? Here is
I have the data table from the jquery plugin dataTables (http://datatables.net/) that I want
I have a data.table object similar to this one library(data.table) c <- data.table(CO =
I have some data in one of my mysql table stored as utf8. The
I have started using data.table. Indeed it is very fast and quite nice syntax.
I have a table column that needs to be limited to a certain width

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.