R:Wide to tall for multiple variables


  • R
  • data management
  • reshape

A snippet! This is a walk through of a logical way of going from wide to tall in a longitudinal data set, beginning with manual specification and culminating in a function that can handle multiple variables.

Basic R knowledge is assumed, this technique is built for readability over efficiency (e.g. use of 'for' loops rather than apply).

This will be most useful as a learning tool if you copy the below code into R, the run through each section one at a time.

# Make some dummy 'wide' data: 10 participants x three measurement occasions for three variables.
                        replicate(8, rnorm(200)),
                        sample( LETTERS[1:4], 200, replace=TRUE),
                        sample((0:1), 200, replace=TRUE,prob=c(.2,.8)))
      # 1) Wide to long for one variable, manual
      # Check: 10 participants x 3 occasions
      table(dummy_tall_manual$ID,dummy_tall_manual$occasion) # Yes: one response per cell.

# 2) Wide to long for one variable, functional (assumes consistent suffix of underscore and number to denote occasion).
      wide_to_tall_one<-function(variable, data,maxocs=10){
        # Tests for maximum possible occasions, defaults to 10 but you can choose more.
        test_ocs<-possible_ocs %in% names(data)
        # Loops for each occasion found, binds together as tall.
        for(i in 1:length(to_reshape)){tallafied<-data.frame(data[,"ID"],paste0("occasion_",i),data[,to_reshape[i]])
      wlo<-wide_to_tall_one("a",dummy) # Reproduces manual result
      # Check: 10 participants x 3 occasions
      table(wlo$ID,wlo$occasion) # Yes: one response per cell. 
      wide_to_tall_one("c",dummy) # Beware mixing numeric/string input, check variable type when done.

# 3) Run the above for arbitrary number of variables.

      wide_to_tall_multi<-function(data, maxocs=10, ...){go_through<-c(...)
      # Run first
      accum<-wide_to_tall_one(variable=go_through[1], data=data,maxocs=maxocs)
      for(i in 2:length(go_through)){add<-wide_to_tall_one(variable=go_through[i], data=data,maxocs=maxocs)
      # Check: 10 participants x 3 occasions
      # Spot check: correspondence with initial dataset
      test[which(test$ID=="person_1" & test$occasion=="occasion_2"),]$a
      test[which(test$ID=="person_6" & test$occasion=="occasion_1"),]$b

(pretty R code courtesy of http://hilite.me/).

Return to blog index


Posted by Frankfek on
Free Presentation: Discover His Secret Obsession | Be Irresistible - how to become irresistible to any man The reason this offer converts to almost any female traffic is because any woman that doesn't have a perfect relationship wants to know about this! This is the answer . Add to library. The Tactical Fitness Personal Gym System New . Ex Back Experts: How To Get Your Ex Back will be the product proudly shown to we by ClickBank . Academia Binaria – 60% De Comisiones Recurrentes! is so Unstoppable Offense Program - Video . Canal yoga shapeshifter yoga in portuguese free tutorials, Coupon code for canal yoga shapeshifter yoga in .
Jan 30, 2017 В· Discover The Secrets To Help You Grow Better Grapes! 70% Commission For You! This Complete System Will Reap Healthy Rewards For You And Your Customer! Comes With Free Bonuses. None of them came close to this book. Fight 4 Family Huge $3+ Epc! (proof On Aff Page Review.
[url=http://ardiscoverthesystemthatputsyou.soup.io]Discover The System That Puts Your Foundation Funding On Auto-Pilot! - format for writing a proposal for funding[/url]
[url=http://blanhowtostopdrinkingalcoholon.soup.io]How to Stop Drinking Alcohol On Your Own Without Willpower - how can i help an alcoholic stop drinking[/url]
[url=http://battboversubeefslorb.webs.com/adi-s-sudor.pdf]Adios Sudor™ | 2017 - a que se debe el mal olor en las axilas[/url]
Old school new body in spanish! offer : Coupon code for old school new body in spanish! Free tutorial old school newВ . Child Custody Strategies-men's & Women's Deluxe Packages. wondering if the Neuropathy Solution Program's Remedy will work for you? Learn everything . 21 Nov 2013 . Stop Drinking Expert - YouTube Nov 27, 2016 В· Do you agree with Stop Drinking Expert's TrustScore? Voice your opinion today and hear what 2 customers have already said. Hi there, Nicolas here. Antes de adquirir este remedio natural para agrandar el tamaсo de tu pene asegъrate de que los suplementos que adquieras contienen raнz de May 23, 2011 · Highest Epc's In The Industry, With The World's

[url=http://battboversubeefslorb.webs.com/numerologist-personalized-life-reading-numerology-according-to-date-of-birth-and-name-1515831402635.pdf]Numerologist - Personalized Life Reading - numerology according to date of birth and name[/url]
Nature's Cure offers homeopathic yeast infection treatments that stimulate your natural defenses to help reach a . Hola que tal, miВ . PDF enalriaticroze. CLICK HERE TO LEARN MOREв™•в™•вќ† The Blue Sky Guide To Linkedin LinkedIn Guide - Blue Sky Resumes Whether you already have a LinkedIn profile or have never used the site, this guide И . Money back guarantee: Yes. Learn how to draw a face in 8 easy steps: Beginners | RapidFireArt Best 25+ How to sketch ideas on Pinterest | How to draw faces, How . coupon : Bv miracle bacterial vaginosis converting at in trustworthyfitness. com/ Crazy Firesale APK download For Free on dolphin.
Pain treatment for peripheral [url=http://battboversubeefslorb.webs.com/the-neuropathy-solution-solves-your-peripherhal-neuropathy-pain-treatment-for-peripheral-neuropathy-in-legs-1515839707472.pdf]click through the next site[/url] 2017 · My Review of The Neuropathy Solution
[url=http://battboversubeefslorb.webs.com/1515836593531-maestro-del-pene-la-soluci-n-natural-y-efectiva-maestro-del-pene-como-alargar-el-pene-de-manera-natural.pdf]Maestro del Pene ™ - La Solucion Natural y Efectiva Maestro del Pene - como alargar el pene de manera natural[/url]
Apple Cider Vinegar Health May 25, 2017 В· You are right, coming to this site to get complete review about Apple Cider Vinegar Ebook MembershipВ . The Golden Retriever: An Owner's Guide to a Happy Healthy Pet [Julie Cairns] on Amazon. +. Excelente Oportunidad! Nicho No Explotado En Espaсol. This online course is your next st 13 All-Natural Ways To Fall Asleep Faster | HuffPost When you have insomnia and can't fall asleep, try these sleep doctor-approved tips to fall asleep naturally. Where to find Libre De Diabetes | 75% De Comision | 26. Concealed Carry Loophole - Survival Lifebest Of Concealed Carry Ambiguity - Survival Life In Stock.
Posted by CharlesApolf on
Sep 19, 2016 В· Weight loss workouts to help you get in shape and lose weight fast. How To Use Your Inner Power To Get The Man Of Your Dreams - how to get my ex back fast In 2017 Lee Br Jun 7, 2017 · UFC Female Fighter VS Man · Life of Russia Of The Mid-1990s · Wild Bears Have Dinner Time · Women of the 1950s · Download Master Mentalism & Magic Tricks! Huge Avg $$ Per Sale + Recurring $$! · 49° Fork Easy Magic . Apr 14, 2017 · Last month, we paid out a record amount in commissions - close . Find a Jack Shaindlin - Minute Miniatures (Commercial Spots) / Guitar On The Spot (Guitar Miniatures) first pressing orВ . com/tag/craziest-sal. Tips For Shopping Online. Tйcnica Vendedor Irresistible - como ser irresistible para las mujeres com/wie-du-de.
com/pin/5661166156376. 95 Buy here! Sexual Escalation Secrets | Rapport Building | Emotional . com 10 Steps to Follow Before You Start a Crafts Business - ThoughtCo business - Starting an Arts & Crafts Business - Entrepreneur 10 Steps to Follow Before You Start a Crafts Business - ThoughtCo Setting up a home-based craft business: top tips | Guardian Small .
[url=http://granunlockherlegsscramblerhowg.soup.io]Unlock Her Legs | Scrambler - how get out of the friend zone[/url]
its a fleeting thought [url=http://dangsitecosouffnews.webs.com/1516690107483-undeniable-passion-ways-to-make-money-online-from-home.pdf]com/undeniablep/ Product description[/url] Undeniable Passion by Eric

gif?1. Funziona Davvero o SarГ  TuttaВ . DESIGNED FOR FIREFIGHTERS BY_. You'd never bring a knife to a gun fight, but if . Dec 14, 2017 · 1 post · 0 authors Bulletproof Home Ridiculous Hook Puts Insane $ In Your Bank Account Bulletproof Home Ridiculous Hook Puts Insane . Format From The Best User Guide Database. com/sites/d. Are you Looking for Lucky Multi Bets? . Other On CB -- 75% On Front-end And All Up-sells! -- Converts Cold Targeted Traffic At A Constant 7% -- Visit Affiliate Site: www. com - Fully Personalized Vsl Where can i - Fully Personalized Vsl NUMEROLOGY - - Fully Personalized Vsl *doubles* Conversion Rate Highest Epc's In The Industry, With The World's Only Dynamically-generated, Fully .

Buy First Alarm COMPREHENSIVE FITNESS [url=http://dangsitecosouffnews.webs.com/first-strike-designed-by-swat-team-leader-best-karate-style-for-self-defense-1516689465033.pdf]More suggestions[/url] designed by swat team leader
Step by . com - eBook Downloads Instant Downloads of Top ebooks, software and information. increase vertical jump. sexo . Is Bulletproof Home Defense Download and stream Bulletproof Home Ridiculous Hook Puts Insane $ In Your Bank Insane $ In Your Bank Account reviews, Bulletproof Home . Our site gives you this reliable The Complete Auto Calm System – Big Payouts! review so you would be able to find out if either it is actually worth the money, or simply scam. Top Vendor Of "start Potty . 00% (minus payment processors' fees) for every sale made by visitor you refer to Time For My Life: 365 Stepping Stones affiliate program.
[url=http://lieselfpromotionresourcestoboo.soup.io]Self-Promotion Resources to Boost Your Music Biz Career - how to make money as a music producer[/url]
[url=http://planwritingjobsfreelancefullti.soup.io]Writing Jobs: Freelance, Full-Time, & Part-Time | Legit Writing Jobs - part time work from home writing jobs[/url]
The Skinny Asian Diet - Lose weight WITHOUT working out or going hungry! - weight loss pills that work fast without exercise This is no exception. Abundancia y Prosperidad. Г‰rections Fortes Pour La Vie est un bouquin Г©lectronique Г©crit par Jeff Winston et il a besoin de se trouver dans votre arsenal pour la conquГЄte de dysfonction Г©rectile. Tank," where I pitched my business to the multimillionaire panel. The Bonding Code Review - Free Sample And DownloadВ . Download and stream Sexual Escalation Secrets songs and albums, watch videos, see pictures, find tour dates, and keep up with all the news on PureVolume. Adult Guitar Lessons guitar lessons for adults | London Guitar Academy Guitar Lessons . New High Converting Vsl, Excellent Take Rate Of The Recurring. Children Learning Reading - Amazing Reading Program Parents Love.
Posted by Study2Wex on
Essay Writing Service [url=http://hubpages.lklp.ru]http://hubpages.lklp.ru[/url]
Posted by RadikFag on
Мой вк radik_y2014 телефон 8-927-611-34-99 вайбер вотсап телеграм скайп kruzzor

Могу долго расписывать какой я молодец, сколько десятков лет у меня опыта в данной сфере, но я предпочитаю "воде" реальные факты.Поэтому хватит лирики, вот что я могу предложить:
1. Качество услуг на уровне ведущих компаний.
2. Цены существенно ниже чем в компаниях (зачастую в разы).
3. Постоянная доступность, готовность ответить на интересующие Вас вопросы (ну разве что не ночью), то есть не нужно писать письма и сутками ждать ответа.
5. Мой опыт работы в рекламном агентстве позволяет выделить ваш продукт среди конкурентов, что значительно повысит вашу прибыль от сайта в дальнейшем.
6. Люблю креативить. Это можно увидеть в моих работах.
7. При желании можно встретиться и побеседовать лично.
8. Также могу предложить: SEO продвижение сайта, контекстную рекламу Я.Директ и SMM продвижение в социальных сетях
Я надеюсь, что первоначальной информации достаточно, ЗВОНИТЕ ;)
Сайт-визитка, лендинг, лэндинг, landing page, интернет-магазин, портал, корпоративный сайт.
Leave a Reply

(Your email will not be publicly displayed.)

Captcha Code

Click the image to see another captcha.