[R] How can I delete column yhat AND STILL retain the order of Response?
BR_email
br at dmstat1.com
Sat Apr 1 21:13:56 CEST 2017
Rui:
Thanks. I will try it.
FYI: I did attached the data, but here it is re-attached.
Thanks, again.
Bruce
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 of
> 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
>
>
>
More information about the R-help
mailing list