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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:29:45+00:00 2026-05-28T21:29:45+00:00

I have a data set from a text file, 5000 stock’s with 751 data

  • 0

I have a data set from a text file, 5000 stock’s with 751 data points for 3 years worth of data, it goes from day 1 to 751 then the next stock

    N     stock  date price
    1        S1 70516  9.11
    2        S1 70517  9.00
    .......................
    5718864  S5000 100330  64.8
    5718865  S5000 100331  64.6

I can load the data using:

data(txt) <- read.table("C:\\test.txt", header=T)

after this however im stuck and i cant find anything on the exchange or google how can i load this into a matrix where there are 751 rows and 5000 coloumns and each point corresponds to just the price

    E1 price     E5000 price
day1   1 ........  1
..                 ..
..                 ..
day751 ........... 1  
  • 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-28T21:29:46+00:00Added an answer on May 28, 2026 at 9:29 pm

    Take a look at cast from the reshape package. You can change your data from a “long” format to a “wide” format and back again. There is also native R functions, reshape for example, but I feel the reshape or reshape2 package provide an easier interface.

    > dat<-data.frame(stock=letters[1:10], date=rep(1:10,each=10), price=round(runif(100),2))
    > head(dat)
      stock date price
    1     a    1  0.84
    2     b    1  0.46
    3     c    1  0.43
    4     d    1  0.99
    5     e    1  0.86
    6     f    1  0.03
    > cast(date~stock, data=dat, value="price")
       date    a    b    c    d    e    f    g    h    i    j
    1     1 0.84 0.46 0.43 0.99 0.86 0.03 0.56 0.09 0.66 0.43
    2     2 0.46 0.78 0.80 0.90 0.20 0.87 0.73 0.65 0.35 0.24
    3     3 0.12 0.16 0.57 0.10 0.40 0.05 0.68 0.53 0.67 0.74
    4     4 0.45 0.26 0.63 0.98 0.78 0.29 0.59 0.63 0.62 0.13
    5     5 0.21 0.79 0.83 0.36 0.11 0.12 0.64 0.86 0.35 0.18
    6     6 0.14 0.31 0.63 0.48 0.86 0.57 0.32 0.70 0.89 0.99
    7     7 0.85 0.41 0.29 0.57 0.05 0.80 0.32 0.13 0.10 0.53
    8     8 0.03 0.71 0.48 0.57 0.09 0.88 0.70 0.22 0.68 0.78
    9     9 0.83 0.52 0.24 0.82 0.86 0.87 0.53 0.38 0.58 0.78
    10   10 0.36 0.05 0.95 0.41 0.73 0.20 0.62 0.08 0.98 0.50
    > 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that parses in data from a comma delimited text file.
I have two results from a data set. I want to add both results
I have a set of XSDs from which I generate data access classes, stored
I am trying to use a textreader to retrieve data from a text file
I am trying to tokenize my data that I get from my text file.
I have an application that imports data read from text files from a directory
I have a series of numbers (in a text file) from 90,000 to 1,000,000
I am trying to write data from form inputs to a text file using
I have a binary data file and need to retrieve some data from it.
I need to know how to read data from tabbed delimited text file in

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.