How to make a dodged bar graph using multiple csv data ?

Dear all,
I am completely a beginner to R programming but I can understand if I get help. I need to make a dodged bar graph using multple CSV files, around 4 files. I need to combine them to make a graph similar to in the representation added below. I want to plot the count of each file in the same graph as percentages in the x-axis and add only labels to the y-axis.
I am attaching a single .csv data here in the codes.Similarly, I have to add 3 more sets to the project. I need to consider only the Type field.

I would be really helpful if anyone could give me a fix for this.
Thank you for your patience

library(datapasta)

Ascending_VV <- tibble::tribble(
~FID, ~SourceID,        ~Type,
   0,         1, "Lineaments",
   1,         3, "Lineaments",
   2,         4, "Lineaments",
   3,         5, "Lineaments",
   4,         6, "Lineaments",
   5,         7, "Lineaments",
   6,         8, "Lineaments",
   7,         9, "Lineaments",
   8,        10, "Lineaments",
   9,        11, "Lineaments",
  10,        12, "Lineaments",
  11,        14, "Lineaments",
  12,        15, "Lineaments",
  13,        16, "Lineaments",
  14,        17, "Lineaments",
  15,        18, "Lineaments",
  16,        19,  "Artifacts",
  17,        20, "Lineaments",
  18,        26, "Lineaments",
  19,        27, "Lineaments",
  20,        28,  "Artifacts"
)
head(Ascending_VV)
#> # A tibble: 6 x 3
#>     FID SourceID Type      
#>   <dbl>    <dbl> <chr>     
#> 1     0        1 Lineaments
#> 2     1        3 Lineaments
#> 3     2        4 Lineaments
#> 4     3        5 Lineaments
#> 5     4        6 Lineaments
#> 6     5        7 Lineaments

Hi Gokul, welcome!

We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:

1 Like

Thanks for the edit suggestion, I think now it may help for the solution.

I think you should separate this into two different questions, first, you need to combine the content of your csv files into one dataframe, for that you could do something similar to this (assuming that the column names in all your csv files are equal).

library(tidyverse)
library(stringr)

# make a list of your csv files
list_of_files <- list.files(path = "path/to/your/files",
                            recursive = TRUE,
                            pattern = "\\.csv$")
# Read and combine your csv files into a dataframe
df <- list_of_files %>%
  setNames(nm = .) %>% 
  map_df(read.csv, .id = "file_name")

Then, with the content of that dataframe we could address the bar graph issue more easily.

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