1

I have some trouble in R and hope to find some help here.

I have a data output from a loop of the following form, whereas the number of countries can vary:

> data
$Australia
   HITTypeId    HITId    Valid
1   123          555     TRUE

$India
   HITTypeId    HITId    Valid
 1  456          888     TRUE

Now what I am looking for, is to create a data table that gives my automatically something of the following form:

  country       HITTypeId      HITId    Valid
1  Austria         123          555     TRUE
2  Belgium         456          888     TRUE

I would appreciate any help!

2
  • I think you've got a named list of data.frames. You can use do.call(rbind, yourlist) to convert to a single data.frame where country will be the row.names. If you can provide the output of str(yourlist) or dput(head(yourlist)) you will likely get an even better answer Commented Apr 3, 2013 at 14:16
  • @justin, your comment was not visible when I answered. Post it as an answer so I can delete mine. Commented Apr 3, 2013 at 14:19

1 Answer 1

2

Use this function:

do.call(rbind, data)
Sign up to request clarification or add additional context in comments.

1 Comment

Whoever ends up with the answer of record should note that the country names will end up not as a variable but as row names, but that last piece can be added via result$country <- rownames(result) or something.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.