Adding headers/ identifiers to List of lists in R
1
0
Entering edit mode
8.7 years ago

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 • 3.7k views
ADD COMMENT
1
Entering edit mode

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

ADD REPLY
1
Entering edit mode
8.7 years ago

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 COMMENT

Login before adding your answer.

Traffic: 1675 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6