如何在子目录列表

时间:2017-09-19 20:30:22

标签: r

我想将“_quants”添加到样本$ sample中包含的文件夹名称列表中。当我使用以下内容时:

files <- file.path(dir, "quants", samples$sample, "_quants")

> dir
[1] "E:/ubuntu-shared/salmonTutorial/"
> samples$sample

 [1] DRR016125 DRR016126 DRR016127 DRR016128 DRR016129 DRR016130 DRR016131 DRR016132 DRR016133 DRR016134 DRR016135 DRR016136 DRR016137 DRR016138 DRR016139
[16] DRR016140
16 Levels: DRR016125 DRR016126 DRR016127 DRR016128 DRR016129 DRR016130 DRR016131 DRR016132 DRR016133 DRR016134 DRR016135 DRR016136 DRR016137 ... DRR016140

我明白了:

[1] "E:/ubuntu-shared/salmonTutorial//quants/DRR016125/_quants"

如何删除双//并使用file.path()将“_quants”附加到“DRR016125”以获得所需的内容:

[1] "E:/ubuntu-shared/salmonTutorial/quants/DRR016125_quants"
[2] "E:/ubuntu-shared/salmonTutorial/quants/DRR016126_quants"

1 个答案:

答案 0 :(得分:1)

使用base::paste0的解决方案:

function upload()
{
          var x = document.getElementById("plan_upload");
          var numOfFiles= x.files.length;
          for (var i = 0; i < numOfFiles; i++) 
          {
                var file = x.files[i];
                var plan_type='${param.par_type}'
                var formdata = new FormData();
                formdata.append("plan_upload", file);
                var ajax = new XMLHttpRequest();
                ajax.addEventListener("error", errorHandlerPlanUpload, false);
                ajax.addEventListener("abort", abortHandlerPlanUpload, false);
                ajax.onreadystatechange = function  ()
                {   
                    if (ajax.readyState==4 && ajax.status==200)
                    {
                        if(i== numOfFiles-1)
                        {
                            alert('Загрузка файлов успешно завершена!');
                            window.opener.location.reload()
                            window.close();
                        }               
                    }
                }  
                ajax.open("POST", "MultipleFileUpload?par_type="+plan_type,false);
                ajax.send(formdata);
            }
} 

dir <- "E:/ubuntu-shared/salmonTutorial/" samples <- list(sample = c("DRR016125", "DRR016126", "DRR016127")) paste0(dir, "quants", samples$sample, "_quants") [1] "E:/ubuntu-shared/salmonTutorial/quantsDRR016125_quants" [2] "E:/ubuntu-shared/salmonTutorial/quantsDRR016126_quants" [3] "E:/ubuntu-shared/salmonTutorial/quantsDRR016127_quants" - 连接向量(转换为字符后),即输出单个字符串。当您通过多个paste0时,它会为每个样本执行此操作。