multiple-columns

R data.table multi column coversion by names [duplicate]

让人想犯罪 __ 提交于 2019-12-02 06:53:33
This question already has an answer here: How to apply same function to every specified column in a data.table 6 answers Let DT be a data.table: DT<-data.table(V1=factor(1:10), V2=factor(1:10), ... V9=factor(1:10),) Is there a better/simpler method to do multicolumn factor conversion like this: DT[,`:=`( Vn1=as.numeric(V1), Vn2=as.numeric(V2), Vn3=as.numeric(V3), Vn4=as.numeric(V4), Vn5=as.numeric(V5), Vn6=as.numeric(V6), Vn7=as.numeric(V7), Vn8=as.numeric(V8), Vn9=as.numeric(V9) )] Column names are totally arbitrary. David Arenburg Yes, the most efficient would be probably to run set in a for

three column web design with variable sides

痴心易碎 提交于 2019-12-02 06:08:11
I've been trying to come up with a way to create a 3 column web design where the center column has a constant width and is always centered. The columns to the left and right are variable. This is trivial in tables, but not correct semantically. I haven't been able to get this working properly in all current browsers. Any tips on this? Use this technique , and simply specify a fixed width for the centre column. Check this out: http://www.glish.com/css/2.asp And replace the width: xx% for #maincenter by a fixed value. Seems to work when I change it with Firebug, worth a shot? #maincenter { width

Extracting a series of integers using a loop

倾然丶 夕夏残阳落幕 提交于 2019-12-02 06:02:34
I have some data where I want to extract the frequency with which the integers appear. Here is some sample data: df <- read.table(header=T, text="A B C D 1 1 5 3 1 2 1 2 3 2 3 2 3 5 3 4 1 4 5 3 5 3 1 4 2 6 5 2 5 1 ") df I can loop through these and get the counts as follows: for (i in 1:5){ print(colSums(df==i)) } But every time I try to store the output I get an error. What is the neatest way to store the resultant output in a dataframe? I think I'm getting confused about the way to store data that's run through a loop. Thanks for your help. We can use mtabulate library(qdapTools) t(mtabulate

know the number of columns from text file, separated by space or tab

不问归期 提交于 2019-12-02 05:21:48
问题 I need to know the number of columns from a text file with floats. I've made like this to know the number of lines: inFile.open(pathV); // checks if file opened if(inFile.fail()) { cout << "error loading .txt file for reading" << endl; return; } // Count the number of lines int NUMlines = 0; while(inFile.peek() != EOF){ getline(inFile, dummyLine); NUMlines++; } inFile.close(); cout << NUMlines-3 << endl; // The file has 3 lines at the beginning that I don't read A line of the .txt : 189.53 58

Add a new column to an existing matrix in MATLAB?

懵懂的女人 提交于 2019-12-02 04:38:35
I have a matrix with two columns, one of which is the date and another of which is a quantity that I have to perform some operations on. I wanted to add a third column to my existing matrix. I was going to go about this by formulating the third column as a column vector, and then adding it on to my existing matrix (although I am not sure how to add another column onto a matrix either- any help would be much appreciated!) For my third column, I wanted to divide 399 by the (180,2) element in my existing matrix, and then each element in my new matrix would be formed by multiplying the value in

Set Column Width in DataSheet View in Split Form

爱⌒轻易说出口 提交于 2019-12-02 04:22:49
Hi I have an Access Database and a simple Change Record Table. I also have a Form where I have got all the fields in the top half of the screen and a Datasheet View in the Bottom. See below. I am trying to set the column widths evenly distributed across the entire width of the screen but so far been unsuccessful. My code is as follows : Private Sub Form_Load() Dim currentFormWidth As Integer currentFormWidth = Me.Width MsgBox ("Current width of my form is : " & currentFormWidth) Dim standardColumnWidth As Integer standardColumnWidth = currentFormWidth / 13 ' Columns of Data to display Me

Chrome and Soundcloud embed issue with CSS3 columns

删除回忆录丶 提交于 2019-12-02 04:09:25
问题 In Chrome when I place a soundcloud embed into a css3 column it always jumps out of the container?! NOTES: I've noticed if its in the first column the embed no longer tries to jump. This only happens in Chrome, safari is unaffected. DEMO (viewed in Chrome 38): http://jsfiddle.net/52u9qe8r/2/ . <!DOCTYPE html> <html> <head> <title></title> <style> .columns{ -webkit-columns: 100px 2; columns: 100px 2; background:red; text-align:left; } body{ background:yellow; } .soundcloud{ background:lime;

How to print columns one after the other in bash?

主宰稳场 提交于 2019-12-02 03:46:20
问题 Is there any better methods to print two or more columns into one column, for example input.file AAA 111 BBB 222 CCC 333 output: AAA BBB CCC 111 222 333 I can only think of: cut -f1 input.file >output.file;cut -f2 input.file >>output.file But it's not good if there are many columns, or when I want to pipe the output to other commands like sort . Any other suggestions? Thank you very much! 回答1: With awk awk '{if(maxc<NF)maxc=NF; for(i=1;i<=NF;i++){(a[i]!=""?a[i]=a[i]RS$i:a[i]=$i)} } END{ for(i

Chrome and Soundcloud embed issue with CSS3 columns

∥☆過路亽.° 提交于 2019-12-02 03:18:58
In Chrome when I place a soundcloud embed into a css3 column it always jumps out of the container?! NOTES: I've noticed if its in the first column the embed no longer tries to jump. This only happens in Chrome, safari is unaffected. DEMO (viewed in Chrome 38): http://jsfiddle.net/52u9qe8r/2/ . <!DOCTYPE html> <html> <head> <title></title> <style> .columns{ -webkit-columns: 100px 2; columns: 100px 2; background:red; text-align:left; } body{ background:yellow; } .soundcloud{ background:lime; -webkit-column-break-inside:avoid; -moz-column-break-inside:avoid; -o-column-break-inside:avoid; -ms

How can I add checkbox in tree table

一笑奈何 提交于 2019-12-02 03:13:42
I want to created a Tree with multi-columns. I found this tutorial here (German) and this answer (English). I want to add checkboxes in one column, but I have no idea how to do it. When I return a checkbox to JTreeTable , something show in execute is checkbox detail not checkbox object. How can I get something like this , pictured below? trashgod As shown in Taking the New Swing Tree Table for a Spin , cited here , your implementation of RowModel must return the correct type from getColumnClass() and the correct value from getValueFor() . Values of type Boolean.class will be rendered with a