From hugh@p@r@on@ge @end|ng |rom gm@||@com  Mon May  2 11:24:42 2022
From: hugh@p@r@on@ge @end|ng |rom gm@||@com (Hugh Parsonage)
Date: Mon, 2 May 2022 19:24:42 +1000
Subject: [Rd] 
 New R version - Issue with as.vector coercion on data.frame
In-Reply-To: <8CF8374A-8E45-47FD-BD8A-418102EA6729@eniso-partners.com>
References: <8CF8374A-8E45-47FD-BD8A-418102EA6729@eniso-partners.com>
Message-ID: <CAJmOi+M7RREJx9SJatd2bnwk6X15n0w_mKD7m5-5=7FtmFdvww@mail.gmail.com>

This is intended. From NEWS, a simple text search for "as.vector" reveals

> as.vector() gains a data.frame method which returns a simple named list, also clearing a long standing ?FIXME? to enable as.vector(<data.frame>, mode="list"). This breaks code relying on as.vector(<data.frame>) to return the unchanged data frame.

On Mon, 2 May 2022 at 19:19, Marc Weibel <marc.weibel at eniso-partners.com> wrote:
>
> Hi
>
> I recently upgraded to the latest r version and got an issue with the command as.vector() on a data.frame object. With the previous R version the returned object was a vector but now it is formatted as a list (see below)
>
>
> > futures_quotes
>   SMI Future SMIM Future Euro Stoxx 50 Future S&P 500 Mini Future FTSE 100 Future Nikkei 225 Future
> 1      11999        2871                 3692                4150            7419             26853
> > class(futures_quotes)
> [1] "data.frame"
>
> > as.vector(futures_quotes[1,1:3])
> $`SMI Future`
> [1] 11999
>
> $`SMIM Future`
> [1] 2871
>
> $`Euro Stoxx 50 Future`
> [1] 3692
>
> > class(as.vector(futures_quotes[1,1:3]))
> [1] "list"
>
>
> Can you help me on this ? (I solved the issue temporarily with as.vector(t(futures_quotes[1,1:3]))
>
> Kind regards
> Marc Weibel
>
>
>
>  <http://www.enisopartners.com/>
> Dr. Marc Weibel
> CIO & Partner
> Tel: +41 44 286 17 02
> Mob: +41 78 892 96 55
> E-Mail: marc.weibel at enisopartners.com <mailto: marc.weibel at enisopartners.com>
>
> Eniso Partners AG
> Claridenstrasse 34 | Postfach | 8022 Z?rich
>
>  <https://www.linkedin.com/in/marc-weibel-29a396/>
> Based on previous e-mail correspondence with you and/or an agreement reached with you, Eniso Partners considers itself authorized to contact you via unsecured e-mail. Warning: E-mails can involve SUBSTANTIAL RISKS, e.g. lack of confidentiality, potential manipulation of contents and/or sender's address, incorrect recipient (misdirection), viruses etc. Eniso Partners assumes no responsibility for any loss or damage resulting from the use of e-mails. Eniso Partners recommends in particular that you do NOT SEND ANY SENSITIVE INFORMATION, that you do not include details of the previous message in any reply, and that you enter e-mail address(es) manually every time you write an e-mail. Please notify Eniso Partners immediately if you received this e-mail by mistake or if you do not wish to receive any further e-mail correspondence. If you have received this e-mail by mistake, please completely delete it (and any attachments) and do not forward it or inform any other person of its contents.
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] New R version - Issue with as.vector coercion on data.frame
Hugh Parsonage