直接创建与vennCounts输出相同的对象

时间:2015-11-06 03:41:41

标签: r logic

vennCounts接收存在/不存在的数据,并产生这个传递给vennDiagram的结构,例如。

   t1 t2 t3 Counts
1  0  0  0      0
2  0  0  1     14
3  0  1  0      2
4  0  1  1      2
5  1  0  0      1
6  1  0  1      9
7  1  1  0      4
8  1  1  1      5
attr(,"class")
[1] "VennCounts"

如果我已经知道Counts,我怎样才能直接创建这样的对象传递给vennDiagram?换句话说,我如何追加最后两行?

1 个答案:

答案 0 :(得分:0)

您可以使用

设置对象class(x) <- "VennCounts" 的类
sealed partial class App : Application
    {
        int port = 8000;

        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            StartServer();
        }

        private void StartServer()
        {
            StreamSocketListener listener = new StreamSocketListener();
            listener.BindServiceNameAsync(port.ToString());
            Debug.WriteLine("Bound to port: " + port.ToString());
            listener.ConnectionReceived += async (s, e) =>
                {
                    Debug.WriteLine("Got connection");
                    using (IInputStream input = e.Socket.InputStream)
                    {
                        var buffer = new Windows.Storage.Streams.Buffer(2);
                        await input.ReadAsync(buffer, buffer.Capacity, InputStreamOptions.Partial);       
                    }

                    using (IOutputStream output = e.Socket.OutputStream)
                    {
                        using (Stream response = output.AsStreamForWrite())
                        {
                            response.Write(Encoding.ASCII.GetBytes("Hello, World!"), 0, 1);
                        }
                    }
                };
        }
    }

没有检查以确保您的对象符合VennCounts类,因此您有责任确保它具有完全相同的结构。