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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:17:36+00:00 2026-05-28T17:17:36+00:00

I want to convert the following json and put the values into a data

  • 0

I want to convert the following json and put the values into a data frame. It almost works but as.data.frame() puts everything into one row.

require(rjson)
require(RCurl)

y = getURI(url1)
y
[1] "[{\"close\":5.45836392962902,\"highest\":5.45837200714172,\"lowest\":5.45836392962902,\"open\":5.45837200714172,\"start_time\":\"2012-01-29T18:29:24-08:00\"},{\"close\":5.45837200714172,\"highest\":5.45837200714172,\"lowest\":5.45834791002201,\"open\":5.45835598753471,\"start_time\":\"2012-01-29T18:28:24-08:00\"}]"

x = fromJSON(y)
> str(x)
List of 2
 $ :List of 5
  ..$ close     : num 5.46
  ..$ highest   : num 5.46
  ..$ lowest    : num 5.46
  ..$ open      : num 5.46
  ..$ start_time: chr "2012-01-29T18:29:24-08:00"
 $ :List of 5
  ..$ close     : num 5.46
  ..$ highest   : num 5.46
  ..$ lowest    : num 5.46
  ..$ open      : num 5.46
  ..$ start_time: chr "2012-01-29T18:28:24-08:00"

as.data.frame(x)
     close  highest   lowest     open                start_time  close.1 highest.1 lowest.1   open.1              start_time.1
1 5.458364 5.458372 5.458364 5.458372 2012-01-29T18:29:24-08:00 5.458372  5.458372 5.458348 5.458356 2012-01-29T18:28:24-08:00

Instead of it being on one row. I want them in two rows.

   close    highest   lowest     open                start_time  
1 5.458364  5.458372 5.458364 5.458372 2012-01-29T18:29:24-08:00 
2 5.458372  5.458372 5.458348 5.458356 2012-01-29T18:28:24-08:00

Is there something I can specify in as.data.table for this to work?

EDIT:

do.call(rbind,lapply(x,as.data.frame))

The above was able to coerce it into a data frame, but the time stamp column has two factors. This next part has its own question here

y = do.call(rbind,lapply(x,as.data.frame))
str(x)
'data.frame':   2 obs. of  5 variables:
 $ close     : num  5.46 5.46
 $ highest   : num  5.47 5.46
 $ lowest    : num  5.46 5.46
 $ open      : num  5.46 5.46
 $ start_time: Factor w/ 2 levels "2012-01-29T21:48:24-05:00",..: 1 2

If I try to convert the POSIX format I get

 x$start_time = as.POSIXct(x$start_time)
 x$start_time
[1] "2012-01-29 CST" "2012-01-29 CST"

But it loses the time data.

  • 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-28T17:17:37+00:00Added an answer on May 28, 2026 at 5:17 pm

    You might try:

    do.call(rbind,lapply(x,as.data.frame))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a a following data that I want to convert it to JSON
I want to convert following html code into continuous string using jquery/javascript. <ul> <li>one</li>
I have the following code in Ruby. I want to convert this code into
I have a response object which I want to convert to Json, but somehow
I am receiving JSON-Data and convert it into a Dictionary. Printing the Dictionary results
I want to convert the following string '14 2' into an array of two
In rails you can do the following to convert an object to Json but
I want to convert the following code to ActionScript (mxml works fine): <mx:Panel title=Some
I want to convert the following SQL Query to a SubSonic Query. SELECT [dbo].[tbl_Agency].[ParentCompanyID]
I have the following string: 2010-04-08T12:46:43+00:00 I want to convert that to: 8th April

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.