John Wildman
John Wildman

Reputation: 81

Calculating new variable in R?

I'm trying to create a variable with the same value for each case. Here is the R code that I've tried writing using mutate:

dataset1 %>% as_tibble() %>% mutate(
  pop2 = 55000000
)

dataset1 %>%
  mutate(pop2 = 55000000)

They are both creating new variables within the dataframe. Can I also write this to the dataset?

Upvotes: 2

Views: 73

Answers (1)

Georgery
Georgery

Reputation: 8117

You can.

dataset1 <- dataset1 %>% mutate(pop2 = 55000000)

Upvotes: 2

Related Questions