The difference between Map and map from Purrr package in R

0 votes
Hello, I'm trying to add a name column to all of the components in my list by using the list's names. That is, I have eight tables in my list, each with its own name: table 1 through eight. So I can unlist them later and tell where the table came from.

This post was read, and the code works. By looping through elements in a vector, R may add columns to dataframes in a list.

Map(cbind, mylist, Cluster = names(mylist)) my list
However, I am perplexed by the Map (). Isn't this the map() function from the Purrr package? map() will take the arguments in the order they are given to it (data, function). I looked up Map in the Rstudio help, and it appears to be much more complex. And if I'm going to use the Purrr map, what should I do?
Jun 14 in Data Science by Avinash
• 1,260 points
28 views

1 answer to this question.

0 votes
The tilde just indicates to the map that what follows is a "formula." The first list we're passing (your list of dataframes) is abbreviated as x, and the second list is abbreviated as. The second list we're passing, y, contains the names of the dataframes. Map is for one list, map2 is for two lists (as in your example), and pmap is for three or more lists. mutate(data = mylist[[1]], new column name = names(mylist[[1]]) is the formula for the first df in the list.
answered Jun 14 by Sohail
• 2,960 points

Related Questions In Data Science

0 votes
1 answer

What's the difference between "*" and "+" in lm() in R?

Lm is a fitting method for linear ...READ MORE

answered Jun 24 in Data Science by Sohail
• 2,960 points
23 views
0 votes
0 answers

The difference of na.rm and na.omit in R

I've just started with R and I've ...READ MORE

Jul 22 in Data Science by avinash
• 1,840 points
10 views
0 votes
0 answers

What is the difference between rm() and rm(list=ls())?

The majority of items I've read. They ...READ MORE

Jul 5 in Data Science by avinash
• 1,840 points
9 views
0 votes
0 answers

Forecast Package from R in Python

The greatest tool for time series analysis ...READ MORE

Jul 22 in Data Science by avinash
• 1,840 points
9 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
435 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
478 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
4,346 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
502 views
0 votes
1 answer

Difference between the == and %in% operators in R

percent in percent "returns a vector of ...READ MORE

answered Jun 20 in Data Science by Sohail
• 2,960 points
20 views
0 votes
1 answer

Difference between the == and %in% operators in R

According to help('percent in percent'), percent in ...READ MORE

answered Jun 23 in Data Science by Sohail
• 2,960 points
14 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP