The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Frequency Table to Individual Samples Conversion
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

OtmarGeiss

Italy
4 Posts

Posted - 06/26/2019 :  10:06:50 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2015 b9.2.257
Operating System:Windows 7

Hi,

I would like to convert a frequency table into a list of individual values.

Example:

a) What I have

Size Frequency
30 1
31 4
33 2

b) What I would like to have
--> only one column with all individual samples
30
31
31
31
31
33
33

How can this be done in Origin ?

Thanks !!
Otmar

YimingChen

1617 Posts

Posted - 06/26/2019 :  10:48:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Please create a worksheet with col(A)~ size, col(B)~ frequency, col(C) empty. Then run the following script in script window. (Window: Script Window)

Thanks,
James


function dataset CreateData(dataset ds1, dataset ds2)
{
	dataset ds3;
	ds3.SetSize(total(ds2));
	int idx = 1;
	for (int i = 1; i <= ds2.GetSize(); i++)
	{
		for(int j=1; j <= ds2[i]; j++)
		{ 
			ds3[idx]=ds1[i]; 
			idx++;
		}
	}
	
	return ds3;
}
col(C) = CreateData(col(A),col(B));

Edited by - YimingChen on 06/26/2019 10:48:48 AM
Go to Top of Page

OtmarGeiss

Italy
4 Posts

Posted - 06/26/2019 :  12:15:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks !!
Works perfectly.


quote:
Originally posted by YimingChen

Hi,

Please create a worksheet with col(A)~ size, col(B)~ frequency, col(C) empty. Then run the following script in script window. (Window: Script Window)

Thanks,
James


function dataset CreateData(dataset ds1, dataset ds2)
{
	dataset ds3;
	ds3.SetSize(total(ds2));
	int idx = 1;
	for (int i = 1; i <= ds2.GetSize(); i++)
	{
		for(int j=1; j <= ds2[i]; j++)
		{ 
			ds3[idx]=ds1[i]; 
			idx++;
		}
	}
	
	return ds3;
}
col(C) = CreateData(col(A),col(B));


Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000