Grokbase Groups R r-help October 2015

You need to break down your expression into parts and see what the data is:

[1] "Fred"

[1] 3

[1] 4 7 9

[1] "Mary"

[1] 2

[1] 14 17

Empl[c(2,4)]$family #>> notice only picks the first object
[1] "Fred"

[1] 3

[1] 4 7 9

To get multiple objects, then you need to use some of the 'apply'
functions; in this case 'sapply':

sapply(Empl[c(2,4)], '[[', 'spouse')
family family
"Fred" "Mary"

Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Sun, Oct 4, 2015 at 2:31 PM, FERNANDO MANSITO CABALLERO wrote:

Dear Madam/Sir,

I am trying to understand R and I have come to a stumbling block. i
have written:
Empl <- list(employee="Anna",family=list(spouse="Fred",children=3,
[1] "Fred"
#instead of [1] "Fred" "Mary"
Where am I wrong?

Thank you very much for your patience
Yours truly,
Fernando Mansito

[[alternative HTML version deleted]]

R-help at mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

  [[alternative HTML version deleted]]

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 13 | next ›
Discussion Overview
groupr-help @
postedOct 4, '15 at 6:31p
activeNov 2, '15 at 12:14a



site design / logo © 2018 Grokbase