Regarding executing function in RMD file

HI all,

I have created a function for matrix summary

so data is like values in different columns
col1 col2 col3 col4.........
1 4 3 7
4 3 2 3
4 2 1 5

"multi<-function(data,list,name){
data<-data[unlist(list)]
lst1 <- lapply(names(data[,1:ncol(data)]), function(x) freq(data,x))
lst2 <- lst1[!sapply(lst1, is.null)]
tab<-Reduce(rbind,lst2) %>% sort_desc(Freq)
tab
}"

Welcome in the group !

I think that it would help very much if you included a (small) example of the data that you want to use.

Further some suggestions:

  • enclosing your code in three (or four in case of Rmd chunks) backticks makes it better readable
  • indicate more clearly what is the error (if any) that you are encountering.
  • you seem to use a function sort_desc that I do not know. So this is no code that we (I) can run to see what is wrong. Try to create a reprex ! The main points for a reprex: be as clear as possible and make the problem as small as possible. For example I do not think that the fact that this is running in an Rmd environment matters (but of course I may be wrong).

i have updated all details regarding my requirement my output

I see but you did not meet my requirements for your inputs :slight_smile:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.