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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:15:42+00:00 2026-05-19T17:15:42+00:00

I have imported data relating to about 70 human subjects from three data tables

  • 0

I have imported data relating to about 70 human subjects from three data tables and have merged them into one data frame in R. Some of the 100 fields are straight forward such as date.birth, number.surgeries.lifetime and number.surgeries.12months. Other fields, such as “comments” may contain no value or it may contain one sentence or maybe even several sentences.

Some human subjects have an anomaly, meaning that something is missing or not just right and for those people I have to manually investigate whats up. When I open the data frame as a data frame or even as a table in fix() it is difficult to read. I have to scroll from left to right and then I have to expand some columns by a ridiculous amount to read just one comment.

It would be much better if I could subset the 5 patients I need to explore and report the data as free flowing text. I thought I could do that by exporting to a csv but its difficult to see which fields are what. For example 2001-01-05, 12, 4, had testing done while still living in Los Angeles. That was easy, imagine what happens if there are 100 fields, many are numbers, many are dates, there are several different comment fields.

A better way would be to output a report such as this:
date.birth:2001-01-05, number.surgeries.lifetime:12, number.surgeries.12months:4, comments:will come talk to us on Monday
Each one of the 5 records would follow that format.
field name 1:field 1 value record 1, field name 2:field 2 value record 1…
skip a line (or something easy to see)
field name 1:field 1 value record 2, field name 2:field 2 value record 2

How can I do it?

  • 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-19T17:15:42+00:00Added an answer on May 19, 2026 at 5:15 pm

    How about this?

    set.seed(1)
    age <- abs(rnorm(10, 40, 20)) 
    patient.key <- 101:110
    date.birth <- as.Date("2011-02-02") - age * 365
    number.surgeries.12months <- rnbinom(10, 1, .5)
    number.surgeries.lifetime <- trunc(number.surgeries.12months * (1 + age/10))
    comments <- "comments text here"
    data <- data.frame(patient.key, 
                       date.birth, 
                       number.surgeries.12months, 
                       number.surgeries.lifetime, 
                       comments)
    

    Subset the data by the patients and fields you are interested in:

    selected.patients <- c(105, 109)
    selected.fields <- c("patient.key", "number.surgeries.lifetime", "comments")
    subdata <- subset(data[ , selected.fields], patient.key %in% selected.patients)
    

    Format the result for printing.

    # paste the column name next to each data field
    taggeddata <- apply(subdata, 1, 
                        function(row) paste(colnames(data), row, sep = ":"))
    # paste all the data fields into one line of text
    textdata <- apply(taggeddata, 2, 
                      function(rec) do.call("paste", as.list(rec)))
    # write to a file or to screen
    writeLines(textdata)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pull data from a table I have imported into my
I have a single entry output from a paradox table which is imported into
I have imported an animated GIF as a resource into a picturebox - unfortunitly
I have a ArrayList made up of different elements imported from a db, made
I wrote an ASP.NET page that imported data from an Excel spreadsheet without any
I have a process that bulk inserts into a table from a CSV. I
I have imported the kernel32 library. So, I have the createMutex function available but
I have imported a time series with dates of the following format: test =
I have my CSV file imported as such: records = FasterCSV.read(path, :headers => true,
I have a table that was imported as all UPPER CASE and I would

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.