Question: Adding headers/ identifiers to List of lists in R
0
gravatar for Erika Gedvilaite
3.4 years ago by
United States
Erika Gedvilaite0 wrote:

Hello all,

This is probably a beginner question, but I have been scavaging the internet and cannot find the answer. I want to add a header or an identifier to my list of lists.

I am inporting a csv file that has multiple data points for multiple individuals:

         V1     V2     V3
Tary    23     24       14
Lane    10   15        30
Don      15    30    34

FILE_LIST <- list()
listcsv <- dir(path = "Area_C5_Optimized/", pattern = "*Area_Analysis.csv",full.names = TRUE, recursive = TRUE,no.. = T)
for (x in 1:length(listcsv)){
  FILE_LIST[[x]] <- read.table(file = listcsv[x], header = T, sep = ",", skipNul = T, fill = T)
  colnames(FILE_LIST[[x]]) <- c("V1","V2","V3","V4","V5","V6","V7","V8","V9","V10","V11","V12")
}

I am first summing the totals and the sums

TOTAL_SUMS <- list()
AREA_SUMS <-list()
for (i in 1:length(FILE_LIST)){
  TOTAL_SUMS[[i]] <- list(rowSums(x = FILE_LIST[[i]][, 2:12], na.rm = TRUE))
  AREA_SUMS[[i]] <- list(rowSums(x = FILE_LIST[[i]][, 3:12], na.rm = TRUE))
}

And now I want to create a boxplot for each area, all v3 values by doing this:

V3_females <- list()
par(mfrow=c(1,1))
for (r in 1:length(FILE_LIST)){
  if (length(grep(x = FILE_LIST[[r]][1,1], pattern = "*_females")) > 0){
    V3_females[[r]] <- FILE_LIST[[r]][,3]
  }
  else
    next
}
V3_females <- V3_females[ ! sapply(V3_females, is.null) ]
boxplot(x = V3_females, na.rm = TRUE, main = "C5 Wings Areas by Segment(female) - V3", xlab = "Wing Mutation", ylab = "Area Distribution")

Now for each graph produce I want all of the bottom/column labels to be labeled "Tary, Lane, Don".

How do you do that?

Thank you in advance for all of the advice and help.

Erika

R • 1.2k views
ADD COMMENTlink modified 3.4 years ago by informatics bot570 • written 3.4 years ago by Erika Gedvilaite0
1

type ?boxplot in the R terminal to get usage info, help with arguments and examples :-)

ADD REPLYlink written 3.4 years ago by WouterDeCoster41k
1
gravatar for informatics bot
3.4 years ago by
United States
informatics bot570 wrote:

Did you try:

boxplot(x = V3_females, na.rm = TRUE, main = "C5 Wings Areas by Segment(female) - V3", xlab = "Wing Mutation", ylab = "Area Distribution", names=c("Tary", "Lane", "Don"))
ADD COMMENTlink modified 3.4 years ago • written 3.4 years ago by informatics bot570
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1518 users visited in the last hour