lupak
January 27, 2021, 12:29pm
1
Good day. I can't cope with adding a row in a calculation column.
My sample data
mydf <- data.frame( opis = c('Plan_zamowien', 'Wykonanie_zamowien', 'Plan_liczba', 'Wykonanie_liczba')
, styczen = c(1687, 500 , 222, 300)
, luty = c(2000, 1200, 234, 220))
I would like to get such a result, will you tell me how to do it?
Once you do such a thing, you will have only character columns, so you wont be able to calculate on that frame anymore. i.e. reporting dataframes are 'the last step' in a workflow.
Your issue seems similar to this one that I answered recently...
library(tidyverse)
(raw1 <- tribble(~Month,~Date,~Day,~Mins,~Calories,~Type,
"March",16,"Monday","00:12:20",NA,"Running",
"March",17,"Tuesday","00:44:11",140,"Strength",
"March",19,"Thursday","00:15:42",NA,"Running",
"April",2, "Thursday","00:43:13",140,"Strength",
"April",5, "Sunday","00:30:00,65",NA,"Core",
"April",6, "Monday","00:30:09,90",NA,"Cardio") %>%
mutate(Month=as_factor(Month)))
(smry2 <- group_by(raw1,
Month) %>% summarise(
days=length(unique(Date)),
calorie_sum = sum(Calories,na.rm = TRUE)
))
empty_raw <- slice(raw1, 1) %>%
select(-Month) %>%
mutate_all(.funs = function(x) {
…
Though your case is perhaps simpler as you dont want the summary info in seperate columns but in the same columns.
lupak
January 28, 2021, 8:30pm
3
Thank you for your support.
I obtained the intended effect by changing the order of calculations to the data frame
system
Closed
February 18, 2021, 8:30pm
4
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.