List of lists output


#1

Hi

This is the output of the program below. I am getting what I want; a list of lists, however, I do not understand why a list is icluded in (c) and the elements of the list start and end with a backwards slash in between quotation marks. The output in the IDE dispays the "backwards slash", however the backwards slash does not appear in this editor - may be you can reporduced them in RStudio. How can I eliminate those characters - c("backwrads slash") - ? For instance,

a = list()
b = anyvalue
a <- appemd(a, list(b))
would produce [1]"c("a","\b")". How can I eliminate those characters from the list of lists?

Thanks,

[1] "c(\"150413_JF_GPeps_SIDtarg_GPstdMix_Tryp_2runs_v3_PSMs.txt\", \"160824_JF_udep_tryp_Hi_SIDdda_FULL_NewParse-(05)_PSMs.txt\") 3"
[2] "c(\"160824_JF_udep_tryp_Hi_SIDdda_FULL_NewParse-(05)_PSMs.txt\", \"JF_160426_Dep2Plas_ctryp_Gpep_SIDtargFULL__PSMs.txt\") 3"    
[3] "c(\"160824_JF_udep_tryp_Hi_SIDdda_FULL_NewParse-(05)_PSMs.txt\", \"JF_160426_Dep2Plas_ctryp_Gpep_SIDtargFULL__PSMs.txt\") 3"
ui <- fluidPage(
   headerPanel("Test"),
 
 #textInput('txt','','Text'),
 selectInput("filescombine",label = h5(strong("PLEASE CHOSE FILES TO COMBINE. To undo selection select the selected file again and press the delete key on your keyboard.
                                                   If you wish to make more sets, PLEASE PRESS ADD BUTTON AND CHOSE FILES TO COMBINE")),c(Choose='', list.files("~/Development/fileTest/GLYCOUNT/DATA")), multiple=TRUE, selectize=TRUE),
 actionButton('add','add'),
 verbatimTextOutput("list")
)
  
 server <- function(input, output, session){
   myValues <- reactiveValues(List = list())
  observe({
     if(input$add > 0){
       #myValues$List <- c(isolate(myValues$List), isolate(list(input$txt)))
       myValues$List <- c(isolate(myValues$List), isolate(list(input$filescombine)))
    }
  })
   output$list<-renderPrint({
     myValues$List
     result <- receivelist(myValues$List)
     value <- paste(result$x, result$L)
     value
   })
   
 }
 
 receivelist <- function(myList){
   x <- list()
   x <- append(x, myList)
   L <- length(x)
   #print(paste(x, length(x)))
   list(x = x, L = L)
   
 }
 
 shinyApp(ui = ui, server = server)
 

#2

I'm not sure I understand exactly what your problem is, and I can't run your shiny app directly since it's referencing a file path on your local machine to build the list of options in selectInput(). If I change that to some dummy options instead, I still can't reproduce your problem — there is no rendered output at all.

Can you please edit your example to be self-contained and runnable by someone else, and to demonstrate the output problem you are seeing?

Meanwhile, I'm not sure what you mean about this part:

If I try to reproduce this (correcting the typos and making b a multi-element list), I get:

a <- list()
b <- list("value1", "value 2", 3:5)
a <- append(a, b)

a
#> [[1]]
#> [1] "value1"
#> 
#> [[2]]
#> [1] "value 2"
#> 
#> [[3]]
#> [1] 3 4 5

If I run your receivelist() function and associated logic outside of your app I get:

b <- list("value 1", "value 2")

receivelist <- function(myList){
  x <- list()
  x <- append(x, myList)
  L <- length(x)
  #print(paste(x, length(x)))
  list(x = x, L = L)
  
}

result <- receivelist(b)
value <- paste(result$x, result$L)
value
#> [1] "value 1 2" "value 2 2"

#3

The problem is in the format of the output: There is a c(...) in front of the file names. In other words, I do not understand why the symbol "c" (vector) appears in front of the files. Additionally, there is a "backwards slash" symbol at the beginning and end of each file name which does not appear in this editor. This happens while rendering the output, which I forgot to include in my previous post - verbatimTextOutput("list") -.

[1] "c("150413_JF_GPeps_SIDtarg_GPstdMix_Tryp_2runs_v3_PSMs.txt", "160824_JF_udep_tryp_Hi_SIDdda_FULL_NewParse-(05)_PSMs.txt") 3"
[2] "c("160824_JF_udep_tryp_Hi_SIDdda_FULL_NewParse-(05)_PSMs.txt", "JF_160426_Dep2Plas_ctryp_Gpep_SIDtargFULL__PSMs.txt") 3"
[3] "c("160824_JF_udep_tryp_Hi_SIDdda_FULL_NewParse-(05)_PSMs.txt", "JF_160426_Dep2Plas_ctryp_Gpep_SIDtargFULL__PSMs.txt") 3".

However, If I send the list of lists to another function: output$listOfLists <- renderPrint({
req(myValues$fList)
shinyjs::show("saveBTN")
if(input$saveBTN > 0)
result <- glycoPipe(inFileName(), myValues$fList )

   })

and I print the list using print(), I get the desired output. Please see below.
[[1]]
[1] "150413_JF_GPeps_SIDtarg_GPstdMix_Tryp_2runs_v3_PSMs.txt" "160824_JF_udep_tryp_Hi_SIDdda_FULL_NewParse-(05)_PSMs.txt"

[[2]]
[1] "150413_JF_GPeps_SIDtarg_GPstdMix_Tryp_2runs_v3_PSMs.txt" "160824_JF_udep_tryp_Hi_SIDdda_FULL_NewParse-(05)_PSMs.txt"

[[3]]
[1] "150413_JF_GPeps_SIDtarg_GPstdMix_Tryp_2runs_v3_PSMs.txt" "160824_JF_udep_tryp_Hi_SIDdda_FULL_NewParse-(05)_PSMs.txt"
[3] "JF_160426_Dep2Plas_ctryp_Gpep_SIDtargFULL__PSMs.txt"

A simple example would be:
ui <- fluidPage(
headerPanel("Test"),

textInput('txt','','Text'),
#selectInput("filescombine",label = h5(strong("PLEASE CHOSE FILES TO COMBINE. To undo selection select the selected file again and press the delete key on your keyboard.
# If you wish to make more sets, PLEASE PRESS ADD BUTTON AND CHOSE FILES TO COMBINE")),c(Choose='', list.files("~/Development/fileTest/GLYCOUNT/DATA")), multiple=TRUE, selectize=TRUE),
actionButton('add','add'),
verbatimTextOutput("list")
)

server <- function(input, output, session){
myValues <- reactiveValues(List = list())
observe({
if(input$add > 0){
myValues$List <- c(isolate(myValues$List), isolate(list(input$txt)))
# myValues$List <- c(isolate(myValues$List), isolate(list(input$filescombine)))
}
})
output$list<-renderPrint({
myValues$List
result <- receivelist(myValues$List)
value <- paste(result$x, result$L)
value
})

}

receivelist <- function(myList){
x <- list()
x <- append(x, myList)
L <- length(x)
#print(paste(x, length(x)))
list(x = x, L = L)

}

shinyApp(ui = ui, server = server)

But the output here does not display the vector c("\filename") symbol.


#4

#5

#6

This topic is continued here: List of List is not producing a list of lists


#7