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 8993315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:10:05+00:00 2026-06-15T23:10:05+00:00

Sorry if the title is confusing. I can import a CSV file into R,

  • 0

Sorry if the title is confusing. I can import a CSV file into R, but once I would like to select one element by providing the row and col index. I got more than one elements. All I want is to use this imported csv as a data.frame, which I can select any columns, rows and single cells. Can anyone give me some suggestions?

Here is the data:

SKU On  Off Duration(hr)    Sales
C010100100  2/13/2012   4/19/2012 17:00 1601    238
C010930200  5/3/2012    7/29/2012 0:00  2088    3
C011361100  2/13/2012   5/25/2012 22:29 2460    110
C012000204  8/13/2012   11/12/2012 11:00    2195    245
C012000205  8/13/2012   11/12/2012 0:00 2184    331

CODE:

Dat = read.table("Dat.csv",header=1,sep=',')
Dat[1,][1]  #This is close to what I need but is not exactly the same
         SKU
1 C010100100
Dat[1,1]    # Ideally, I want to have results only with C010100100
[1] C010100100
3861 Levels: B013591100 B024481100 B028710300 B038110800 B038140800 B038170900 B038260200 B038300700 B040580700 B040590200 B040600400 B040970200 ... YB11624Q1100

Thanks!

  • 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-15T23:10:06+00:00Added an answer on June 15, 2026 at 11:10 pm

    You can convert to character to get the value as a string, and no longer as a factor:

    as.character(Dat[1,1])
    

    You have just one element, but the factor contains all levels.

    Alternatively, pass the option stringsAsFactors=FALSE to read.table when you read the file, to prevent creation of factors for character values:

    Dat = read.table("Dat.csv",header=1,sep=',', stringsAsFactors=FALSE )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the title is confusing sorry, if you can think of a better one, please
I'm sorry for what can be considered a confusing title; but thought of no
Sorry if the title sounds confusing - but this is what I am trying
Sorry for the confusing title, but it basically says it all. Here's the structures
I'm sorry if the title is quite confusing but I am wondering if it's
Sorry about the confusing title. Are there any web IDEs available that can be
Sorry for the confusing title :P I'm sure I should know this but I
I am sorry for the confusing title, I'm not sure how to put into
Sorry for the title may seem confusing. i have 2 element. with no relation
Sorry if the title is confusing but I'm trying to get all comments and

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.