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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:16:33+00:00 2026-05-17T18:16:33+00:00

Below are the first five rows of the imported data in R: data[1:5,] user

  • 0

Below are the first five rows of the imported data in R:

data[1:5,]

    user event_date day_of_week
1 00002781A2ADA816CDB0D138146BD63323CCDAB2 2010-09-04    Saturday
2 00002D2354C7080C0868CB0E18C46157CA9F0FD4 2010-09-04    Saturday
3 00002D2354C7080C0868CB0E18C46157CA9F0FD4 2010-09-07     Tuesday
4 00002D2354C7080C0868CB0E18C46157CA9F0FD4 2010-09-08   Wednesday
5 00002D2354C7080C0868CB0E18C46157CA9F0FD4 2010-09-17      Friday
  distinct_events_a_count total_events_a_count
1                             2                          2
2                             2                          2
3                             1                          3
4                             1                          1
5                             1                          1
  events_a_duration distinct_events_b_count total_events_b_count
1                     615                       1                    1
2                      77                       1                    1
3                     201                       1                    1
4                      44                       1                    1
5                       3                       1                    1
  events_b_duration
1                      47
2                      43
3                     117
4                      74
5                      18

The problem is that the columns 6 and 9 are read as factors and not numerics therefore I can’t perform math operations. In order to convert the imported data to appropriate format I tried to create the structure dataset the following way:

dataset<-data.frame(events_a_duration=as.numeric(c(data[,6])), events_b_duration=as.numeric(c(data[,9])))

but checking the values I noticed that the frame structure doesn’t contain the appropriate values:

 dataset[1,]


events_a_duration events_b_duration
1                   10217                    6184

The values should be 615 and 47.

So what I don’t know is how to create the frame data structure that consists of imported data columns and would be very thankful if anyone could show the way to create the appropriate data structure.

  • 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-05-17T18:16:33+00:00Added an answer on May 17, 2026 at 6:16 pm

    Your problem is that you are converting factors to integers by using the numbers of classes instead of the corresponding values. You can check that classes are numbered in ascending order of the values:

    > as.numeric(factor(c(615,47,42)))
    [1] 3 2 1
    > as.numeric(factor(c(615,42,47)))
    [1] 3 1 2
    > as.numeric(factor(c(615,42,47,37)))
    [1] 4 2 3 1
    > as.numeric(factor(c(615,42,37,47)))
    [1] 4 2 1 3
    

    Use as.numeric(as.character(MyFactor)). See below for instance:

    > as.numeric(as.character(factor(c(615,42,37,47))))
    [1] 615  42  37  47
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My project simplify as below: First, I use application method Data.java to save data.
in the code below at first if statements block (there will be more than
For some weird reason, the codes below are first working, then website is redirecting
Racking my brains on this one. I have the code below: the first stages
I first got an error usign the code below, explaining that DataGridLinkButton' must be
In the first method listed below, the use method, it looks to me like
The code below working for only first div. I can't display other divs when
Below are two ways of reading in the commandline parameters. The first is the
The first one is definitely something that works, but which one below is the
Which one below is correct? First code has no quotes in the $_GET array

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.