From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastien Vauban Subject: Re: Adding `sort' in R makes the output fail Date: Thu, 23 Oct 2014 20:49:42 +0200 Message-ID: <86y4s6wri1.fsf@example.com> References: <86bnp2g8dn.fsf@example.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: (Charles C. Berry's message of "Thu, 23 Oct 2014 09:10:16 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: "Charles C. Berry" Cc: public-emacs-orgmode-mXXj517/zsQ-wOFGN7rlS/M9smdsby/KFg@public.gmane.org "Charles C. Berry" wrote: > On Thu, 23 Oct 2014, Sebastien Vauban wrote: >> >> The following code does return a corrupted answer, while it's supposed >> to return a sorted dataframe. > > Not so. See below. So, that's RStudio that's wrong, in some way? >> --8<---------------cut here---------------start------------->8--- >> #+BEGIN_SRC R :results value replace >> con <- textConnection(" >> index email >> A abc-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org >> B def-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org >> C def-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org >> D ghi-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org >> E abc-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org >> F def-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org") >> df <- read.table(con, header = TRUE) >> sort(table(df$email)) >> #+END_SRC >> >> #+results: >> | 1 | >> | 2 | >> | 3 | >> --8<---------------cut here---------------end--------------->8--- > > You created a `table' object, then you sorted it creating an `array' > object- an object of a different class. > > Is this what you want? > > #+BEGIN_SRC R :results value replace > con <- textConnection(" > index email > A abc-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org > B def-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org > C def-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org > D ghi-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org > E abc-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org > F def-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org") > df <- read.table(con, header = TRUE) > as.table(sort(table(df$email))) > #+END_SRC > > #+RESULTS: > | ghi-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org | 1 | > | abc-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org | 2 | > | def-hcDgGtZH8xNBDgjK7y7TUQ-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org | 3 | Yes, it is. Thanks! Best regards, Seb -- Sebastien Vauban