Thanks Chuck and Rolf.



While Rolf’s code also works on the dput that I actually gave you (a smaller 
subset of the full dataset), it failed to work on the larger dataset, because 
there are further exceptions:





input[[i]]$content[[1]] is sometimes a list, sometimes a character vector, and 
sometimes input[[i]]$content simply returns list().




Chuck’s solution however bypasses this and works on the full dataset (which was 
8mb, which is why I didn’t upload it as a gist).




Best,

Aron




-- 

Aron Lindberg




Doctoral Candidate, Information Systems

Weatherhead School of Management 

Case Western Reserve University

aronlindberg.github.io

On Fri, Feb 20, 2015 at 12:44 AM, Charles Berry <ccbe...@ucsd.edu> wrote:

> Aron Lindberg <aron.lindberg <at> case.edu> writes:
>> 
>> Hi Everyone,
>> 
>> I'm working on a thorny subsetting problem involving list of lists. I've put 
>> a 
> dput of the data here:
>> 
>>      https://gist.githubusercontent.com/aronlindberg/b916dee897d051ac5be5/
> raw/a78cbf873a7e865c3173f943ff6309ea688c653b/dput
>> 
> IIUC, you want the value of every list element that is named "sha" and 
> that name will only apply to atomic objects.
> If so, this should do it. 
>> input <- dget("/tmp/dpt")
>> shas <- unlist( input, use.names=FALSE )[ grepl( "sha", 
>> names(unlist(input)))]
>> input[[67]]$content[[1]]$sha
> [1] "58cf43ecdc1beb7e1043e9de612ecc817b090f15"
>> which(input[[67]]$content[[1]]$sha == shas )
> [1] 194
> HTH,
> Chuck
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to