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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:06:16+00:00 2026-06-08T03:06:16+00:00

I’m simply trying to split my dataframe into several dataframes based on the value

  • 0

I’m simply trying to split my dataframe into several dataframes based on the value of my column intervention, but I’m getting some unexpected output when I try and do this.

Checking I do indeed have a dataframe named raw:

print(class(raw));

yields

[1] "data.frame"

Here’s the dataframe before the split:

  position                                   id equation      intervention
1       -2 D9E4262D-5B6D-ADB8-D605-B97D63437064      9,5            corral
2        1 B2FFB0B0-210E-022F-293A-0ABFDDB3DC4B      2,3            corral
3        1 85905A69-50F7-AF73-7A51-08B8FDCFAF2D      1,2         horseshoe
4       -2 76A55530-5A39-6A73-3216-D276EABFA2F6      3,4 test_intervention
5       -1 4CFA5D1B-EA32-8584-A1C9-540D9FFB24CB      3,4 test_intervention

Then I use

groups <- split(raw, raw$intervention);

and when I print

print(groups);

I get this:

$corral.corral.horseshoe.test_intervention.test_intervention
  position                                   id equation      intervention
1       -2 D9E4262D-5B6D-ADB8-D605-B97D63437064      9,5            corral
2        1 B2FFB0B0-210E-022F-293A-0ABFDDB3DC4B      2,3            corral
3        1 85905A69-50F7-AF73-7A51-08B8FDCFAF2D      1,2         horseshoe
4       -2 76A55530-5A39-6A73-3216-D276EABFA2F6      3,4 test_intervention
5       -1 4CFA5D1B-EA32-8584-A1C9-540D9FFB24CB      3,4 test_intervention

Which doesn’t look like a list of dataframes grouped by intervention. Also notice the strange line

$corral.corral.horseshoe.test_intervention.test_intervention

EDIT

Output of dput(raw):

structure(list(position = list(-2, 1, 1, -2, -1), id = list("D9E4262D-5B6D-ADB8-D605-B97D63437064",
    "B2FFB0B0-210E-022F-293A-0ABFDDB3DC4B", "85905A69-50F7-AF73-7A51-08B8FDCFAF2D",
    "76A55530-5A39-6A73-3216-D276EABFA2F6", "4CFA5D1B-EA32-8584-A1C9-540D9FFB24CB"),
    equation = list("9,5", "2,3", "1,2", "3,4", "3,4"), intervention = list(
        "corral", "corral", "horseshoe", "test_intervention",
        "test_intervention")), .Names = c("position", "id", "equation",
"intervention"), row.names = c(NA, -5L), class = "data.frame")

EDIT
Here’s my full code, it’s small.

#!/usr/local/bin/Rscript --slave
require("rjson", quietly=TRUE);

# First we need to grab the items from the R api, and save them into a data frame
raw = fromJSON(file="http://some/url.com");

#reformats data into dataframe
raw <- as.data.frame(do.call(rbind,raw));
#we need to create a new dataframe formatted according to the needs of catR
groups <- split(raw, raw$intervention);
print(groups); 
#saveRDS(object=fromJSON(file="http://some/url.com"),file="/home/bitnami/IRT_data/core_standard.rda");

I run my code like so:

~/Rscript my_R_file.R
  • 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-08T03:06:17+00:00Added an answer on June 8, 2026 at 3:06 am
    raw1<-read.table(header=T,text="  position                                   id equation      intervention
    1       -2 D9E4262D-5B6D-ADB8-D605-B97D63437064      9,5            corral
    2        1 B2FFB0B0-210E-022F-293A-0ABFDDB3DC4B      2,3            corral
    3        1 85905A69-50F7-AF73-7A51-08B8FDCFAF2D      1,2         horseshoe
    4       -2 76A55530-5A39-6A73-3216-D276EABFA2F6      3,4 test_intervention
    5       -1 4CFA5D1B-EA32-8584-A1C9-540D9FFB24CB      3,4 test_intervention")
    
    groups <- split(raw1, raw1$intervention)
    
    > groups
    $corral
      position                                   id equation intervention
    1       -2 D9E4262D-5B6D-ADB8-D605-B97D63437064      9,5       corral
    2        1 B2FFB0B0-210E-022F-293A-0ABFDDB3DC4B      2,3       corral
    
    $horseshoe
      position                                   id equation intervention
    3        1 85905A69-50F7-AF73-7A51-08B8FDCFAF2D      1,2    horseshoe
    
    $test_intervention
      position                                   id equation      intervention
    4       -2 76A55530-5A39-6A73-3216-D276EABFA2F6      3,4 test_intervention
    5       -1 4CFA5D1B-EA32-8584-A1C9-540D9FFB24CB      3,4 test_intervention
    

    not getting same as you. Seems to work fine

    raw is your dataframe, raw1 is the read.table version

    > str(raw1$intervention)
     Factor w/ 3 levels "corral","horseshoe",..: 1 1 2 3 3
    > str(raw$intervention)
    List of 5
     $ : chr "corral"
     $ : chr "corral"
     $ : chr "horseshoe"
     $ : chr "test_intervention"
     $ : chr "test_intervention"
    

    When you convert the output from RJSON to a data.frame it is creating a dataframe of lists

    this line is your problem

    #reformats data into dataframe
    raw <- as.data.frame(do.call(rbind,raw));
    

    use

     raw2<-data.frame(lapply(raw,unlist))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

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.