Stringr选择位置上的数据。

时间:2018-04-18 21:59:32

标签: r stringr

调用strsplit:

 public string Ssl()
    {
        try
        {
            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
            using (var wc = new WebClient())
            {
                var res = wc.DownloadString("https://untrusted-root.badssl.com/");
                Console.WriteLine(res);
                return res;
            }
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
    }

我以为我可以拉出每个中的倒数第二个值;即4和8通过

example <- (strsplit(data$col, ","))

[[1]]
[1] "1", "2", "3", "4", "5"

[[2]]
[1] "4", "5", "6", "7", "8", "9"

情况不是这样吗?我得到了不寻常的答案

1 个答案:

答案 0 :(得分:0)

两种选择:

sapply(example, function(x) tail(x, 2)[1]) # option 1
sapply(example, function(x) x[length(x)-1]) # option 2