如何使用r解析nls fit(多行文本)文件?

时间:2017-03-02 04:24:25

标签: r

如何使用r?

解析下面给出的nls fit(多行文本)文件
Nonlinear regression model
  model: A ~ BOTTOM + (TOP - BOTTOM)/(1 + 10^((logEC50 - xdata) * hillSlope))
   data: keep
      TOP    BOTTOM hillSlope   logEC50 
  101.027     0.704     1.374    -6.319 
 residual sum-of-squares: 581.7

Number of iterations to convergence: 7 
Achieved convergence tolerance: 1.798e-06

我想得到一个第四行文本的表格作为列标题,第五行数字作为值s显示如下:

TOP      BOTTOM   hillSlope   logEC50 
101.027  0.704    1.374       -6.319

1 个答案:

答案 0 :(得分:2)

使用read.table尝试这三个参数 skip / nrows / header

read.table(text = "Nonlinear regression model
    model: A ~ BOTTOM + (TOP - BOTTOM)/(1 + 10^((logEC50 - xdata) * hillSlope))
     data: keep
        TOP    BOTTOM hillSlope   logEC50 
    101.027     0.704     1.374    -6.319 
   residual sum-of-squares: 581.7

  Number of iterations to convergence: 7 
  Achieved convergence tolerance: 1.798e-06", skip = 3, nrows = 1, header = T)

#      TOP BOTTOM hillSlope logEC50
#1 101.027  0.704     1.374  -6.319

根据@ 42-要求:

  • 使用skip指定在阅读时要忽略的行数;
  • 指定header = T,以便跳过行后的第一行将被读取为标题;
  • 然后你只想再读一行作为正文,用nrows = 1来指定;