[R] subsetting lists....
ccberry @end|ng |rom uc@d@edu
Mon Jun 18 19:00:40 CEST 2018
> On Jun 18, 2018, at 4:15 AM, akshay kulkarni <akshay_e4 using hotmail.com> wrote:
> correction....I want the method without a for loop
Here are two. The first is more readable, but the second is 5 times faster.
mapply("[", YH, iuhV)
unlist(YH, recursive = FALSE, use.names = FALSE)[cumsum( lengths(YH)) - lengths(YH) + iuhV]
> From: akshay kulkarni <akshay_e4 using hotmail.com>
> Sent: Monday, June 18, 2018 4:25 PM
> To: R help Mailing list
> Subject: subsetting lists....
> dear members,
> I have list YH and index vector iuhV. I want to select iuhV from YH[], iuhv from YH[], iuhv from YH[]......iuhv[n] from YH[[n]]...
> How to do this?
> I searched SO and the internet but was bootless....
> Very many thanks for your time and effort.....
> Yours sincerely,
> AKSHAY M KULKARNI
> [[alternative HTML version deleted]]
More information about the R-help