[R] How can I delete column yhat AND STILL retain the order of Response?

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Sat Apr 1 21:37:22 CEST 2017

Eventually you will think to read the Posting Guide, which discusses which attachments are likely to be allowed on the mailing list. Most users find that pasting a minimal amount of data into the main body of the email is the simplest way to be sure the info will get through to someone who can help. 
Sent from my phone. Please excuse my brevity.

On April 1, 2017 12:13:56 PM PDT, BR_email <br at dmstat1.com> wrote:
>Thanks. I will try it.
>FYI: I did attached the data, but here it is re-attached.
>Thanks, again.
>Bruce Ratner, Ph.D.
>The Significant Statistician™
>(516) 791-3544
>Statistical Predictive Analtyics -- www.DMSTAT1.com
>Machine-Learning Data Mining and Modeling -- www.GenIQ.net
>Rui Barradas wrote:
>> Hello,
>> 1) We don't have access to your file firstRdata.csv so what I'll say 
>> is just an untested guess. You can post some of your data with the 
>> following R command.
>> dput(head(Response, 20))  # paste the output of this in a mail
>> 2) First you use read.csv that outputs a data.frame and then do 
>> data.frame(Response). Useless. Response already is a df.
>> 3) I believe the trouble you're facing comes from your use of 
>> attach(). This function is _never_ needed and is cause of all sorts
>> bugs. In particular, what you are ordering is the attached copy of 
>> Response, and all changes you do to it will only have effect on the 
>> copy. The original is left as it were.
>> So run the same code (with the obvious bug yhatResponse$yhat 
>> corrected) but eliminating the 'attach' instruction. And see if it 
>> reorders Response.
>> Hope this helps,
>> Rui Barradas
>> Em 01-04-2017 17:32, BR_email escreveu:
>>> Response    <- read.csv("C:/R_Data/firstRdata.csv", sep=",", 
>>> header=TRUE)
>>> Response
>>> Response    <- data.frame(Response)
>>> attach(Response)
>>> Response
>>> Response    <- Response[order(-yhat),]
>>> Response    <- Response[rev(order(yhatResponse$yhat)),]
>>> Response
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list