Is this the correct way to create a list values?


#1

I want to create a named AccountList with the following “named” list values –
AccountName = “Bob”
AccountBalance = 5500.00

AccountList= list(AccountName= “Bob”, AccountBalance= 5500.00)


#2

This certainly a way to create a list, yes.

I noticed that you've been asking a few getting started with R questions lately. Do you have a good resource for learning the basics of R like this yet? I am sure there are folks here happy to recommend you a few resources if you give some insight into what you're trying to do.


#3

Yes, I am a very complete beginner and unfortunately I do not have any resources and the youtube video I have seen don't have any applications examples to help me analyse how the process really works. I would TRULY appreciate any recommendations I could get


#4

Available for free online.


#5

wow! thank you very much!


#6

Also, google. You will find answers to just about any question you have if you google them.

Oh, and don't hesitate to look at the documentation of functions and packages. For instance:

?list


#7

Yes, google is definitely beneficial to understand the concept. However, my issue is mainly on application. I like seeing scenario examples and see how they are implemented in R. that is what I mainly have issues with at the moment.


#8

But google will often lead you to such examples (for instance on StackOverflow).

With a bit of practice, you will learn what to google to find what you want.


#9

In the realm of self-paced interactive web lessons, I think DataCamp’s offerings are some of the best. Most content requires a paid subscription, but their Introduction to R course is free and gives a taste of the approach:

(All the R lessons: https://www.datacamp.com/courses/tech:r)

There’s a bunch of good stuff in this thread, too:


#10

There is also an online community of learners and mentors working through this book.
https://medium.com/@kierisi/r4ds-the-next-iteration-d51e0a1b0b82 and through twitter via the #R4DS hashtag


#11

I think you'll want another list(...):

AccountList= list(
  list(AccountName= "Bob", AccountBalance= 5500.00),
  list(AccountName= "Ann", AccountBalance= 9900.00)
)

The inner lists are for tupes, and the outer list is for the list of tuples.

From there, the natural next step is to make a table:

> AccountDF = dplyr::bind_rows(AccountList)
> AccountDF
# A tibble: 2 x 2
  AccountName AccountBalance
        <chr>          <dbl>
1         Bob           5500
2         Ann           9900

I find this approach useful sometimes. I think you probably wouldn't run into it on DataCamp, StackOverflow or R4DS, though, so I wanted to mention it (since I think you were on the right track).