List 复制数据帧列表

List 复制数据帧列表,list,dataframe,matrix,List,Dataframe,Matrix,今天我想运行TropFishR包,问题是(对我来说),每个数据都必须排列在列表中。因此,我试图重建alba数据集,以便将来用我自己的数据进行复制。以下是我所做的: library(TropFishR) data("alba") str(alba) #the list contain 4 variables List of 4 $ sample.no : int [1:14] 1 2 3 4 5 6 7 8 9 10 ... $ midLength

今天我想运行TropFishR包,问题是(对我来说),每个数据都必须排列在列表中。因此,我试图重建alba数据集,以便将来用我自己的数据进行复制。以下是我所做的:

    library(TropFishR)
    data("alba")
    str(alba) #the list contain 4 variables

    List of 4
    $ sample.no : int [1:14] 1 2 3 4 5 6 7 8 9 10 ...
    $ midLengths: num [1:14] 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 10.5 ...
    $ dates     : Date[1:7], format: "1976-04-17" "1976-07-02" "1976-09-19" ...
    $ catch     : num [1:14, 1:7] 0 0 0 1 1 1 3 9 5 0 ...
     ..- attr(*, "dimnames")=List of 2
     .. ..$ : NULL
     .. ..$ : chr [1:7] "1976.29315068493" "1976.50136986301" "1976.71780821918" "1976.95616438356" ...
     - attr(*, "class")= chr "lfq"
这就是我所做的:

   #1 We create sample.no
    sample.no <- c(1:14)
    sample.no
   #2 We create "midlengths"
    midlengths <- seq(from = 1.5, to = 14.5, by = 1)
    midlengths
   #3 We create "dates"
    dates <- as.Date(c("1976-04-17","1976-07-02", "1976-09-19", "1976-12-15", "1977-02-18",
               "1977-04-30", "1977-06-24"))
    dates
   #4 We create "catch"
    catch <- as.matrix(read.csv(file.choose(), header=T)) 
    #I copied the alba length freq data, move it to excel and imported as csv file
    colnames(catch)<-NULL
    print(catch)
   #5 create list files 
    synLFQb <- list(sample.no,midlengths,dates,catch)
    synLFQb #just checked if it turned out to be as desired format
   #6 create a name for the data list
    names(synLFQb) <- c("sample.no","midlengths","dates","catch")
   #Finally, we need to assign the class lfq to our new object in    order to allow it to be recognized by other TropFishR functions, e.g. plot.lfq:
    class(synLFQb) <- "lfq"
但是,每次我尝试执行此简单命令时:

    plot(synLFQb, Fname="catch", hist.sc = 1)
它导致了以下错误:

    > plot(synLFQb, Fname="catch", hist.sc = 1)
    Error in plot.window(...) : need finite 'ylim' values
    In addition: Warning messages:
    1: In min(x, na.rm = na.rm) :
       no non-missing arguments to min; returning Inf
    2: In max(x, na.rm = na.rm) :
       no non-missing arguments to max; returning -Inf

任何帮助都将不胜感激

请确保列表中的中间长度向量用大写字母“L”命名为“中间长度”。我希望这能在您的示例中起到作用。

谢谢@tokami的回答,但问题是我应该使用TropFishR的默认命令重新创建列表。
    > plot(synLFQb, Fname="catch", hist.sc = 1)
    Error in plot.window(...) : need finite 'ylim' values
    In addition: Warning messages:
    1: In min(x, na.rm = na.rm) :
       no non-missing arguments to min; returning Inf
    2: In max(x, na.rm = na.rm) :
       no non-missing arguments to max; returning -Inf