Zeke
Zeke

Reputation: 57

Summarizing in R changing data output

I am trying to summarize a type of product, where it is split each element with a "-". The code can be seen below:

testAct <- pipeline %>%
    group_by(Unique.Opportunity.ID) %>%
    filter(row_number() == 1) %>%
    ungroup() %>%
    group_by(Company.Name, Sales.Team) %>%
    summarize(Product.Family = paste(c(Product.Family), collapse="-"))
seqAct <- testAct %>%
    ungroup() %>%
    group_by(Product.Family) %>%
    summarize(count = n())

The output is shows the "product.family" variable as '1-6', where is should be something like 'FDS-RDS'... I am not sure why it is converting it into integers.

                          Company.Name             Sales.Team Product.Family
                                <fctr>                 <fctr>          <chr>
                             Example1               Americas             1-6
                             Example1               Americas             1-7
                             Example1                WEMEA 2             8-7
                             Example1                    CEE         3-3-4-7
                             Example1                WEMEA 1             7-7
                             Example1               Americas             1-6
                             Example1                WEMEA 1             7-7
                             Example1                WEMEA 2             8-7
                             Example1                    CEE         3-3-6-4

Any assistance on this would be very helpful!

Upvotes: 0

Views: 45

Answers (1)

leeum
leeum

Reputation: 274

It is tough to say without you doing a dput of the data, if you could, please add to your question the output from:

dput(head(df,20))

My guess is that the variables are factors and it for some reason is writing down the number associated with the factor. On the column you are referencing, I would do this before running my code:

df$column <- as.character(df$column)

Again. tough to help without seeing the data.

Upvotes: 1

Related Questions