Working in R 3.6.1 (64) bit. Used readxl to get a data frame into R (Named "RawShift". I made 6 variables (class: "character") that are lists of user names. Each list is named for the team that user is on.
I want to use Mutate to create a column that has the team the user is from.
INTeam = C("user1", "user2",...)
OFTeam = C("user3", "user4",...)
When I had been working with Data frame this code worked:
RawShift <- RawShift %>% mutate(Team =case_when(
`username` %in% OFTeam ~ "Office",
`username` %in% INTeam ~ "Industrial"
))
Now I've taken that and done "as_tibble" on my Raw Shift, it won't error not will it work. Is this a case of not understanding the Tibble access methods ("", [], ., [[]]). Is it worth worry about or just do a hack job and convert using data frame then convert to a tibble later? I've looked into the benefits of Tibble over dataframe and seems to me I'd be better using Tibbles but cant seem to get this working. Have tried using "$", "." etc before the %in% without luck so far. Thanks for any advice/help.
c
instead ofC
– akruncode
Data <- as_tibble(Data) # Define Teams OFTeam <- c("Scott, Andrews", "Linda, Kuang") INTeam <- c("Lee, Vanessa", "Chan, Stephen", "Hartmann, Jonathan") # Create "Team" Column in Shift Data based on Account Assessor Data <- Data %>% mutate(Team = case_when( "User Name" %in% OFTeam ~ "Office", "User Name" %in% INTeam ~ "Industrial" )) – SMShead(iris) %>% as_tibble %>% mutate(new = case_when(Species == "setosa" ~ "hello")) # A tibble: 6 x 6 Sepal.Length Sepal.Width Petal.Length Petal.Width Species new
– akrunlibrary(tibble)
– akrun