循环中的quantmod :: chartSeries()行为不符合预期

时间:2018-10-21 00:10:37

标签: r charts quantmod

为什么结果是8页的PDF而不是8页的1页PDF?

void find_simple_circles(struct t *t_temp)
{
    int circles_t;
    struct s *s_temp;

    circles_t = 0;

    while (t_temp != NULL)      //Check all transaction nodes of current g_node.
    {
                                //If a transaction node has direction 0 or 2 and it is not yet visited "t_temp->to_user->state == WHITE".
        if ((t_temp->direction == 0 || t_temp->direction == 2) && (t_temp->to_user->state == WHITE))
        {
            weight_input(t_temp);   //Insert its weight to the stack.
            if (strcmp(s_head->username, t_temp->to_user->username) == 0)
            {                       //If a transaction node, transacts with the username (graph node) I am looking for, print whole stack.
                circles_t++;        
                circles++;         
                print_assist(s_head);
            }
            else                                                //If it transacts with someone else,
            {   
                t_temp->to_user->state = GRAY;                  //that someone else becomes proccessed and cannot be visited for the time being "GRAY".
                s_temp = new_s_node(t_temp->to_user);           //Create a new stack member with the above username.
                add_s_to_list(s_temp, t_temp);                  //Add it to the stack list.
                find_simple_circles(t_temp->to_user->gt_node);  //Recursively call find_simple_circles(), with the transactions list of that username.
                remove_last(s_head);                            //When recurse returns, remove the last member of the stack list.
                t_temp->to_user->state = WHITE;                 //And set the username to "WHITE"(can be visited again).
            }
        }
        if((circles_t == 0) && (t_temp->t_next == NULL))        //If no circles where found while proccessing a username
            t_temp->to_user_t->to_user->state = BLACK;          //Set it to "BLACK"(cannot be visited).
        t_temp = t_temp->t_next;                                //Step through all transactions of a username.
    }
    return;
}

enter image description here

1 个答案:

答案 0 :(得分:2)

您可以使用lapplychart_Series在一页上获取多个图表:

pdf(file = "charts.pdf")
par(mfrow=c(4,2))
lapply(x,function(x) chart_Series(x))
dev.off()

编辑以获取股票代号:

要在图表上输入正确的股票代号,您可以像这样将name参数添加到chart_Series:

name = unlist(strsplit(names(x[[1]])[1],'[.]'))[1]

enter image description here