How to layer data by a column

Source: Internet
Author: User

Original link: HTTP://WWW.DATASTUDY.CC/TO/13

Most of the time, the data we get is a aggregated piece of data, such as the data in our example, that has aggregated all the warehouse data. But when we're modeling, how do we do layered processing if we want to split them up? It's actually very simple, we can use the Split function. Split (x, F, drop = FALSE, ...) Let's look at the case of layered processing: Data Please download from Baidu disk: Link: http://pan.baidu.com/s/1kFxoy Password: TNBF data <-read.csv ("D: \\data\\20150922\\data.csv ", fileencoding=" UTF8 ", Stringsasfactors=false) datas <-split (data, data$ warehouse) Result < -C (); for (d in Datas) {#这里执行我们需要的建模, #我这里演示就用了个计算平均数m <-mean (d$ price); #把建模后的模型加入到结果数组中result <-append (result, m)} result These are the most basic models of layered processing, including the layering of data, and the assembly of processed results into a vector return.

How to layer data by a column

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.