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
 All Forums
 Origin Forum
 Origin Forum
 Frequency Table to Individual Samples Conversion

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
OtmarGeiss Posted - 06/26/2019 : 10:06:50 AM
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
2   L A T E S T    R E P L I E S    (Newest First)
OtmarGeiss Posted - 06/26/2019 : 12:15:04 PM
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));


YimingChen Posted - 06/26/2019 : 10:48:20 AM
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));

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000