How to combine a frequency count of multiple columns with a transposition of categorical variables linked to...












0















Let's assume I have a very large dataset storing thousands of households profiles which sizes are up to 11 members.
The order of the data is examplified in the table below where I have gender of each member of the household, his/her profession (let's say 20 types of predefined categories) and his/her revenue for each income source.



Gender1 <- c("M","F")
Gender2 <- c("F", "M")
Work1 <- c("A", "B")
Work2 <- c("B","A")
RevenueA <- c(10,20)
RevenueB <- c(20,10)
df <- data.frame(Gender1, Gender2, Work1, Work2, RevenueA, RevenueB)


enter image description here



Now, my R code challange is to get a frequency count of how many males and females work in each codified sector (work 1, work 2 up to 20 categories) and the average revenue value declared by each gender across all the predefined categories. I wish to keep the types of sectors as labels in the output table. The exemplification of the output is shown in the table below:



enter image description here



What is the most efficient way to get the proposed output without entering the label for each work category in the code? I would also like to repeat the same logic while considering location as primary aggregation, like in the following table:



enter image description here



On a last note, the dataframe has multiple NAs values as well.
Thank you for your support!










share|improve this question

























  • can u dput() sample data

    – sai saran
    Nov 17 '18 at 14:26
















0















Let's assume I have a very large dataset storing thousands of households profiles which sizes are up to 11 members.
The order of the data is examplified in the table below where I have gender of each member of the household, his/her profession (let's say 20 types of predefined categories) and his/her revenue for each income source.



Gender1 <- c("M","F")
Gender2 <- c("F", "M")
Work1 <- c("A", "B")
Work2 <- c("B","A")
RevenueA <- c(10,20)
RevenueB <- c(20,10)
df <- data.frame(Gender1, Gender2, Work1, Work2, RevenueA, RevenueB)


enter image description here



Now, my R code challange is to get a frequency count of how many males and females work in each codified sector (work 1, work 2 up to 20 categories) and the average revenue value declared by each gender across all the predefined categories. I wish to keep the types of sectors as labels in the output table. The exemplification of the output is shown in the table below:



enter image description here



What is the most efficient way to get the proposed output without entering the label for each work category in the code? I would also like to repeat the same logic while considering location as primary aggregation, like in the following table:



enter image description here



On a last note, the dataframe has multiple NAs values as well.
Thank you for your support!










share|improve this question

























  • can u dput() sample data

    – sai saran
    Nov 17 '18 at 14:26














0












0








0








Let's assume I have a very large dataset storing thousands of households profiles which sizes are up to 11 members.
The order of the data is examplified in the table below where I have gender of each member of the household, his/her profession (let's say 20 types of predefined categories) and his/her revenue for each income source.



Gender1 <- c("M","F")
Gender2 <- c("F", "M")
Work1 <- c("A", "B")
Work2 <- c("B","A")
RevenueA <- c(10,20)
RevenueB <- c(20,10)
df <- data.frame(Gender1, Gender2, Work1, Work2, RevenueA, RevenueB)


enter image description here



Now, my R code challange is to get a frequency count of how many males and females work in each codified sector (work 1, work 2 up to 20 categories) and the average revenue value declared by each gender across all the predefined categories. I wish to keep the types of sectors as labels in the output table. The exemplification of the output is shown in the table below:



enter image description here



What is the most efficient way to get the proposed output without entering the label for each work category in the code? I would also like to repeat the same logic while considering location as primary aggregation, like in the following table:



enter image description here



On a last note, the dataframe has multiple NAs values as well.
Thank you for your support!










share|improve this question
















Let's assume I have a very large dataset storing thousands of households profiles which sizes are up to 11 members.
The order of the data is examplified in the table below where I have gender of each member of the household, his/her profession (let's say 20 types of predefined categories) and his/her revenue for each income source.



Gender1 <- c("M","F")
Gender2 <- c("F", "M")
Work1 <- c("A", "B")
Work2 <- c("B","A")
RevenueA <- c(10,20)
RevenueB <- c(20,10)
df <- data.frame(Gender1, Gender2, Work1, Work2, RevenueA, RevenueB)


enter image description here



Now, my R code challange is to get a frequency count of how many males and females work in each codified sector (work 1, work 2 up to 20 categories) and the average revenue value declared by each gender across all the predefined categories. I wish to keep the types of sectors as labels in the output table. The exemplification of the output is shown in the table below:



enter image description here



What is the most efficient way to get the proposed output without entering the label for each work category in the code? I would also like to repeat the same logic while considering location as primary aggregation, like in the following table:



enter image description here



On a last note, the dataframe has multiple NAs values as well.
Thank you for your support!







r frequency transpose summary frequency-distribution






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 17 '18 at 15:02







Nicola

















asked Nov 17 '18 at 14:18









NicolaNicola

132110




132110













  • can u dput() sample data

    – sai saran
    Nov 17 '18 at 14:26



















  • can u dput() sample data

    – sai saran
    Nov 17 '18 at 14:26

















can u dput() sample data

– sai saran
Nov 17 '18 at 14:26





can u dput() sample data

– sai saran
Nov 17 '18 at 14:26












1 Answer
1






active

oldest

votes


















0














Something like that would work on your example (I've added a location to the dataframe):



library(tidyverse)

Gender1 <- c("M","F")
Gender2 <- c("F", "M")
Work1 <- c("A", "B")
Work2 <- c("B","A")
RevenueA <- c(10,20)
RevenueB <- c(20,10)
Location <- c("ABC", "ABC")
df <- data.frame(Location, Gender1, Gender2, Work1, Work2, RevenueA, RevenueB)

df %>%
gather(key_gen, value_gen, which(grepl("Gender", colnames(.)))) %>%
gather(key_work, value_work, which(grepl("Work", colnames(.)))) %>%
gather(key_reven, value_reven, which(grepl("Revenue", colnames(.)))) %>%
mutate(
gen_id = gsub(".*(\d+$)", "\1", key_gen),
work_id = gsub(".*(\d+$)", "\1", key_work),
reven_id = gsub("Revenue", "", key_reven),
key_work = "Work", key_gen = "Gender", key_reven = "Revenue"
) %>%
filter(gen_id == work_id & value_work == reven_id) %>%
select(-contains("_id"), -key_reven) %>%
add_count(value_gen, value_work) %>%
group_by(value_gen, value_work) %>%
mutate(
mean_reven = paste0("MeanRevenue", value_work),
mean_reven_n = mean(value_reven, na.rm = TRUE),
key_work = paste0(key_work, value_work)
) %>% ungroup() %>%
distinct(Location, key_gen, value_gen, key_work, n, mean_reven, mean_reven_n) %>%
spread(key_gen, value_gen) %>%
spread(key_work, n) %>%
spread(mean_reven, mean_reven_n) %>%
mutate_at(vars(contains("Work"), contains("MeanRevenue")), funs(replace(., is.na(.), 0)))


Output:



  Location Gender WorkA WorkB MeanRevenueA MeanRevenueB
<fct> <chr> <dbl> <dbl> <dbl> <dbl>
1 ABC F 0 2 0 15
2 ABC M 2 0 15 0


However, I believe your data may be more complex. If this doesn't scale well to your dataset, it would be helpful if you could provide us a more complex example that better resembles your original dataframe.






share|improve this answer


























  • Definetly helpful contribution, but I got the following error ~Error in filter(., gen_id == work_id & value_work == reven_id): object 'gen_id' not found

    – Nicola
    Nov 17 '18 at 15:48











  • It may be that your dataset is different than your example, e.g. that column names are not the same, or something similar. Could you check if there are substantial differences between your dataframe and the example you've provided?

    – arg0naut
    Nov 17 '18 at 15:52











  • That's useful, I had to apply dplyr:: in front of the filter function and it worked on the small sample that was here proposed. Yet, when running it on a larget set of structured data I get into another error Error: Duplicate identifiers for rows (1, 2), (8, 9, 10), (12, 15), (3, 5), (11, 14). I wonder if it has something to do with the way to spread the data when there are repeated identifiers and how to sort it.

    – Nicola
    Nov 17 '18 at 16:41













  • You can insert row number as a variable but wouldn't advise so unless we can see the dataframe. Can you augment your data example with more data points resembling your data?

    – arg0naut
    Nov 17 '18 at 17:26











  • I actually just kept the proposed example and added a few more random data points but that's when I got the duplicate identifiers error.

    – Nicola
    Nov 17 '18 at 22:06











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53352065%2fhow-to-combine-a-frequency-count-of-multiple-columns-with-a-transposition-of-cat%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Something like that would work on your example (I've added a location to the dataframe):



library(tidyverse)

Gender1 <- c("M","F")
Gender2 <- c("F", "M")
Work1 <- c("A", "B")
Work2 <- c("B","A")
RevenueA <- c(10,20)
RevenueB <- c(20,10)
Location <- c("ABC", "ABC")
df <- data.frame(Location, Gender1, Gender2, Work1, Work2, RevenueA, RevenueB)

df %>%
gather(key_gen, value_gen, which(grepl("Gender", colnames(.)))) %>%
gather(key_work, value_work, which(grepl("Work", colnames(.)))) %>%
gather(key_reven, value_reven, which(grepl("Revenue", colnames(.)))) %>%
mutate(
gen_id = gsub(".*(\d+$)", "\1", key_gen),
work_id = gsub(".*(\d+$)", "\1", key_work),
reven_id = gsub("Revenue", "", key_reven),
key_work = "Work", key_gen = "Gender", key_reven = "Revenue"
) %>%
filter(gen_id == work_id & value_work == reven_id) %>%
select(-contains("_id"), -key_reven) %>%
add_count(value_gen, value_work) %>%
group_by(value_gen, value_work) %>%
mutate(
mean_reven = paste0("MeanRevenue", value_work),
mean_reven_n = mean(value_reven, na.rm = TRUE),
key_work = paste0(key_work, value_work)
) %>% ungroup() %>%
distinct(Location, key_gen, value_gen, key_work, n, mean_reven, mean_reven_n) %>%
spread(key_gen, value_gen) %>%
spread(key_work, n) %>%
spread(mean_reven, mean_reven_n) %>%
mutate_at(vars(contains("Work"), contains("MeanRevenue")), funs(replace(., is.na(.), 0)))


Output:



  Location Gender WorkA WorkB MeanRevenueA MeanRevenueB
<fct> <chr> <dbl> <dbl> <dbl> <dbl>
1 ABC F 0 2 0 15
2 ABC M 2 0 15 0


However, I believe your data may be more complex. If this doesn't scale well to your dataset, it would be helpful if you could provide us a more complex example that better resembles your original dataframe.






share|improve this answer


























  • Definetly helpful contribution, but I got the following error ~Error in filter(., gen_id == work_id & value_work == reven_id): object 'gen_id' not found

    – Nicola
    Nov 17 '18 at 15:48











  • It may be that your dataset is different than your example, e.g. that column names are not the same, or something similar. Could you check if there are substantial differences between your dataframe and the example you've provided?

    – arg0naut
    Nov 17 '18 at 15:52











  • That's useful, I had to apply dplyr:: in front of the filter function and it worked on the small sample that was here proposed. Yet, when running it on a larget set of structured data I get into another error Error: Duplicate identifiers for rows (1, 2), (8, 9, 10), (12, 15), (3, 5), (11, 14). I wonder if it has something to do with the way to spread the data when there are repeated identifiers and how to sort it.

    – Nicola
    Nov 17 '18 at 16:41













  • You can insert row number as a variable but wouldn't advise so unless we can see the dataframe. Can you augment your data example with more data points resembling your data?

    – arg0naut
    Nov 17 '18 at 17:26











  • I actually just kept the proposed example and added a few more random data points but that's when I got the duplicate identifiers error.

    – Nicola
    Nov 17 '18 at 22:06
















0














Something like that would work on your example (I've added a location to the dataframe):



library(tidyverse)

Gender1 <- c("M","F")
Gender2 <- c("F", "M")
Work1 <- c("A", "B")
Work2 <- c("B","A")
RevenueA <- c(10,20)
RevenueB <- c(20,10)
Location <- c("ABC", "ABC")
df <- data.frame(Location, Gender1, Gender2, Work1, Work2, RevenueA, RevenueB)

df %>%
gather(key_gen, value_gen, which(grepl("Gender", colnames(.)))) %>%
gather(key_work, value_work, which(grepl("Work", colnames(.)))) %>%
gather(key_reven, value_reven, which(grepl("Revenue", colnames(.)))) %>%
mutate(
gen_id = gsub(".*(\d+$)", "\1", key_gen),
work_id = gsub(".*(\d+$)", "\1", key_work),
reven_id = gsub("Revenue", "", key_reven),
key_work = "Work", key_gen = "Gender", key_reven = "Revenue"
) %>%
filter(gen_id == work_id & value_work == reven_id) %>%
select(-contains("_id"), -key_reven) %>%
add_count(value_gen, value_work) %>%
group_by(value_gen, value_work) %>%
mutate(
mean_reven = paste0("MeanRevenue", value_work),
mean_reven_n = mean(value_reven, na.rm = TRUE),
key_work = paste0(key_work, value_work)
) %>% ungroup() %>%
distinct(Location, key_gen, value_gen, key_work, n, mean_reven, mean_reven_n) %>%
spread(key_gen, value_gen) %>%
spread(key_work, n) %>%
spread(mean_reven, mean_reven_n) %>%
mutate_at(vars(contains("Work"), contains("MeanRevenue")), funs(replace(., is.na(.), 0)))


Output:



  Location Gender WorkA WorkB MeanRevenueA MeanRevenueB
<fct> <chr> <dbl> <dbl> <dbl> <dbl>
1 ABC F 0 2 0 15
2 ABC M 2 0 15 0


However, I believe your data may be more complex. If this doesn't scale well to your dataset, it would be helpful if you could provide us a more complex example that better resembles your original dataframe.






share|improve this answer


























  • Definetly helpful contribution, but I got the following error ~Error in filter(., gen_id == work_id & value_work == reven_id): object 'gen_id' not found

    – Nicola
    Nov 17 '18 at 15:48











  • It may be that your dataset is different than your example, e.g. that column names are not the same, or something similar. Could you check if there are substantial differences between your dataframe and the example you've provided?

    – arg0naut
    Nov 17 '18 at 15:52











  • That's useful, I had to apply dplyr:: in front of the filter function and it worked on the small sample that was here proposed. Yet, when running it on a larget set of structured data I get into another error Error: Duplicate identifiers for rows (1, 2), (8, 9, 10), (12, 15), (3, 5), (11, 14). I wonder if it has something to do with the way to spread the data when there are repeated identifiers and how to sort it.

    – Nicola
    Nov 17 '18 at 16:41













  • You can insert row number as a variable but wouldn't advise so unless we can see the dataframe. Can you augment your data example with more data points resembling your data?

    – arg0naut
    Nov 17 '18 at 17:26











  • I actually just kept the proposed example and added a few more random data points but that's when I got the duplicate identifiers error.

    – Nicola
    Nov 17 '18 at 22:06














0












0








0







Something like that would work on your example (I've added a location to the dataframe):



library(tidyverse)

Gender1 <- c("M","F")
Gender2 <- c("F", "M")
Work1 <- c("A", "B")
Work2 <- c("B","A")
RevenueA <- c(10,20)
RevenueB <- c(20,10)
Location <- c("ABC", "ABC")
df <- data.frame(Location, Gender1, Gender2, Work1, Work2, RevenueA, RevenueB)

df %>%
gather(key_gen, value_gen, which(grepl("Gender", colnames(.)))) %>%
gather(key_work, value_work, which(grepl("Work", colnames(.)))) %>%
gather(key_reven, value_reven, which(grepl("Revenue", colnames(.)))) %>%
mutate(
gen_id = gsub(".*(\d+$)", "\1", key_gen),
work_id = gsub(".*(\d+$)", "\1", key_work),
reven_id = gsub("Revenue", "", key_reven),
key_work = "Work", key_gen = "Gender", key_reven = "Revenue"
) %>%
filter(gen_id == work_id & value_work == reven_id) %>%
select(-contains("_id"), -key_reven) %>%
add_count(value_gen, value_work) %>%
group_by(value_gen, value_work) %>%
mutate(
mean_reven = paste0("MeanRevenue", value_work),
mean_reven_n = mean(value_reven, na.rm = TRUE),
key_work = paste0(key_work, value_work)
) %>% ungroup() %>%
distinct(Location, key_gen, value_gen, key_work, n, mean_reven, mean_reven_n) %>%
spread(key_gen, value_gen) %>%
spread(key_work, n) %>%
spread(mean_reven, mean_reven_n) %>%
mutate_at(vars(contains("Work"), contains("MeanRevenue")), funs(replace(., is.na(.), 0)))


Output:



  Location Gender WorkA WorkB MeanRevenueA MeanRevenueB
<fct> <chr> <dbl> <dbl> <dbl> <dbl>
1 ABC F 0 2 0 15
2 ABC M 2 0 15 0


However, I believe your data may be more complex. If this doesn't scale well to your dataset, it would be helpful if you could provide us a more complex example that better resembles your original dataframe.






share|improve this answer















Something like that would work on your example (I've added a location to the dataframe):



library(tidyverse)

Gender1 <- c("M","F")
Gender2 <- c("F", "M")
Work1 <- c("A", "B")
Work2 <- c("B","A")
RevenueA <- c(10,20)
RevenueB <- c(20,10)
Location <- c("ABC", "ABC")
df <- data.frame(Location, Gender1, Gender2, Work1, Work2, RevenueA, RevenueB)

df %>%
gather(key_gen, value_gen, which(grepl("Gender", colnames(.)))) %>%
gather(key_work, value_work, which(grepl("Work", colnames(.)))) %>%
gather(key_reven, value_reven, which(grepl("Revenue", colnames(.)))) %>%
mutate(
gen_id = gsub(".*(\d+$)", "\1", key_gen),
work_id = gsub(".*(\d+$)", "\1", key_work),
reven_id = gsub("Revenue", "", key_reven),
key_work = "Work", key_gen = "Gender", key_reven = "Revenue"
) %>%
filter(gen_id == work_id & value_work == reven_id) %>%
select(-contains("_id"), -key_reven) %>%
add_count(value_gen, value_work) %>%
group_by(value_gen, value_work) %>%
mutate(
mean_reven = paste0("MeanRevenue", value_work),
mean_reven_n = mean(value_reven, na.rm = TRUE),
key_work = paste0(key_work, value_work)
) %>% ungroup() %>%
distinct(Location, key_gen, value_gen, key_work, n, mean_reven, mean_reven_n) %>%
spread(key_gen, value_gen) %>%
spread(key_work, n) %>%
spread(mean_reven, mean_reven_n) %>%
mutate_at(vars(contains("Work"), contains("MeanRevenue")), funs(replace(., is.na(.), 0)))


Output:



  Location Gender WorkA WorkB MeanRevenueA MeanRevenueB
<fct> <chr> <dbl> <dbl> <dbl> <dbl>
1 ABC F 0 2 0 15
2 ABC M 2 0 15 0


However, I believe your data may be more complex. If this doesn't scale well to your dataset, it would be helpful if you could provide us a more complex example that better resembles your original dataframe.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 17 '18 at 19:19

























answered Nov 17 '18 at 15:30









arg0nautarg0naut

2,187314




2,187314













  • Definetly helpful contribution, but I got the following error ~Error in filter(., gen_id == work_id & value_work == reven_id): object 'gen_id' not found

    – Nicola
    Nov 17 '18 at 15:48











  • It may be that your dataset is different than your example, e.g. that column names are not the same, or something similar. Could you check if there are substantial differences between your dataframe and the example you've provided?

    – arg0naut
    Nov 17 '18 at 15:52











  • That's useful, I had to apply dplyr:: in front of the filter function and it worked on the small sample that was here proposed. Yet, when running it on a larget set of structured data I get into another error Error: Duplicate identifiers for rows (1, 2), (8, 9, 10), (12, 15), (3, 5), (11, 14). I wonder if it has something to do with the way to spread the data when there are repeated identifiers and how to sort it.

    – Nicola
    Nov 17 '18 at 16:41













  • You can insert row number as a variable but wouldn't advise so unless we can see the dataframe. Can you augment your data example with more data points resembling your data?

    – arg0naut
    Nov 17 '18 at 17:26











  • I actually just kept the proposed example and added a few more random data points but that's when I got the duplicate identifiers error.

    – Nicola
    Nov 17 '18 at 22:06



















  • Definetly helpful contribution, but I got the following error ~Error in filter(., gen_id == work_id & value_work == reven_id): object 'gen_id' not found

    – Nicola
    Nov 17 '18 at 15:48











  • It may be that your dataset is different than your example, e.g. that column names are not the same, or something similar. Could you check if there are substantial differences between your dataframe and the example you've provided?

    – arg0naut
    Nov 17 '18 at 15:52











  • That's useful, I had to apply dplyr:: in front of the filter function and it worked on the small sample that was here proposed. Yet, when running it on a larget set of structured data I get into another error Error: Duplicate identifiers for rows (1, 2), (8, 9, 10), (12, 15), (3, 5), (11, 14). I wonder if it has something to do with the way to spread the data when there are repeated identifiers and how to sort it.

    – Nicola
    Nov 17 '18 at 16:41













  • You can insert row number as a variable but wouldn't advise so unless we can see the dataframe. Can you augment your data example with more data points resembling your data?

    – arg0naut
    Nov 17 '18 at 17:26











  • I actually just kept the proposed example and added a few more random data points but that's when I got the duplicate identifiers error.

    – Nicola
    Nov 17 '18 at 22:06

















Definetly helpful contribution, but I got the following error ~Error in filter(., gen_id == work_id & value_work == reven_id): object 'gen_id' not found

– Nicola
Nov 17 '18 at 15:48





Definetly helpful contribution, but I got the following error ~Error in filter(., gen_id == work_id & value_work == reven_id): object 'gen_id' not found

– Nicola
Nov 17 '18 at 15:48













It may be that your dataset is different than your example, e.g. that column names are not the same, or something similar. Could you check if there are substantial differences between your dataframe and the example you've provided?

– arg0naut
Nov 17 '18 at 15:52





It may be that your dataset is different than your example, e.g. that column names are not the same, or something similar. Could you check if there are substantial differences between your dataframe and the example you've provided?

– arg0naut
Nov 17 '18 at 15:52













That's useful, I had to apply dplyr:: in front of the filter function and it worked on the small sample that was here proposed. Yet, when running it on a larget set of structured data I get into another error Error: Duplicate identifiers for rows (1, 2), (8, 9, 10), (12, 15), (3, 5), (11, 14). I wonder if it has something to do with the way to spread the data when there are repeated identifiers and how to sort it.

– Nicola
Nov 17 '18 at 16:41







That's useful, I had to apply dplyr:: in front of the filter function and it worked on the small sample that was here proposed. Yet, when running it on a larget set of structured data I get into another error Error: Duplicate identifiers for rows (1, 2), (8, 9, 10), (12, 15), (3, 5), (11, 14). I wonder if it has something to do with the way to spread the data when there are repeated identifiers and how to sort it.

– Nicola
Nov 17 '18 at 16:41















You can insert row number as a variable but wouldn't advise so unless we can see the dataframe. Can you augment your data example with more data points resembling your data?

– arg0naut
Nov 17 '18 at 17:26





You can insert row number as a variable but wouldn't advise so unless we can see the dataframe. Can you augment your data example with more data points resembling your data?

– arg0naut
Nov 17 '18 at 17:26













I actually just kept the proposed example and added a few more random data points but that's when I got the duplicate identifiers error.

– Nicola
Nov 17 '18 at 22:06





I actually just kept the proposed example and added a few more random data points but that's when I got the duplicate identifiers error.

– Nicola
Nov 17 '18 at 22:06


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53352065%2fhow-to-combine-a-frequency-count-of-multiple-columns-with-a-transposition-of-cat%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?