names

how to assign to the names() attribute of the value of a variable in R

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 05:11:29
In R, "assign('x',v)" sets the object whose name is 'x' to v. Replace 'x' by the result of applying a text function to a variable x. Then "assign" shows its worth. Unfortunately, "assign(paste('names(','x',')',sep=''),v)" fails. So if 'x' is a variable x, I can set its value, but I can't give it names for its elements. Can one work around this? a parse-eval trick maybe? Thanks. In the form you ask question there is no need to assign names. If you x exists then you do names(x) <- v . This is right way to do this. If your variable name is unknown (i.e. dynamically created) then you could use

DataGridView Edit Column Names

一世执手 提交于 2019-11-29 03:57:45
Is there any way to edit column names in a DataGridView? I don't think there is a way to do it without writing custom code. I'd implement a ColumnHeaderDoubleClick event handler, and create a TextBox control right on top of the column header. Ryan Spears You can also change the column name by using: myDataGrid.Columns[0].HeaderText = "My Header" but the myDataGrid will need to have been bound to a DataSource . Bjørn Otto Vasbotten You can edit the header directly: dataGridView1.Columns[0].HeaderCell.Value = "Created"; dataGridView1.Columns[1].HeaderCell.Value = "Name"; And so on for as many

Checking if a domain name is registered

戏子无情 提交于 2019-11-29 02:33:04
问题 How would I go about checking if a domain name is registered? I was thinking about checking if it has a corresponding IP but it doesn't seem to work as well as I had hoped. Is there a solution in either PHP or Python that can check? 回答1: "Registered" doesn't mean "assigned an IP address". To know whether a domain name is registered, you'll need to do a whois query. For Python, there's pywhois, but from its web site it seems somewhat immature. Also see this SO question. For PHP, there's...

Get the column names of a python numpy ndarray

梦想的初衷 提交于 2019-11-28 20:49:05
问题 Let's say I have a data file called data.txt that looks like: TIME FX FY FZ 0 10 5 6 1 2 4 7 2 5 2 6 ... In python run: import numpy as np myData = np.genfromtxt("data.txt", names=True) >>> print myData["TIME"] [0, 1, 2] The names at the top of my data file will vary, so what I would like to do is find out what the names of my arrays in the data file are. So I would like something like: >>> print myData.names [TIME, F0, F1, F2] I thought about just to read in the data file and get the first

Dataframes in a list; adding a new variable with name of dataframe

耗尽温柔 提交于 2019-11-28 20:40:36
I have a list of dataframes which I eventually want to merge while maintaining a record of their original dataframe name or list index. This will allow me to subset etc across all the rows. To accomplish this I would like to add a new variable 'id' to every dataframe, which contains the name/index of the dataframe it belongs to. Edit: "In my real code the dataframe variables are created from reading multiple files using the following code, so I don't have actual names only those in the 'files.to.read' list which I'm unsure if they will align with the dataframe order: mylist <- llply(files.to

How to pass dynamic column names in dplyr into custom function?

独自空忆成欢 提交于 2019-11-28 19:34:14
I have a dataset with the following structure: Classes ‘tbl_df’ and 'data.frame': 10 obs. of 7 variables: $ GdeName : chr "Aeugst am Albis" "Aeugst am Albis" "Aeugst am Albis" "Aeugst am Albis" ... $ Partei : chr "BDP" "CSP" "CVP" "EDU" ... $ Stand1971: num NA NA 4.91 NA 3.21 ... $ Stand1975: num NA NA 5.389 0.438 4.536 ... $ Stand1979: num NA NA 6.2774 0.0195 3.4355 ... $ Stand1983: num NA NA 4.66 1.41 3.76 ... $ Stand1987: num NA NA 3.48 1.65 5.75 ... I want to provide a function which allows to compute the difference between any value, and I would like to do this using dplyr s mutate

assign headers based on existing row in dataframe in R

…衆ロ難τιáo~ 提交于 2019-11-28 16:30:51
After transforming a dataframe, I would like to assign heads/names to the columns based on an existing row . My headers are currently: row.names X2 X3 X4 X5 X6 X7 X8 X9 ... I would like to get rid of that and use the following row as column headers (without having to type them out since I have many). The only solution I have for this is to export and re-load the data (with header=T). Vishnu Jayanand The key here is to unlist the row first. colnames(DF) <- as.character(unlist(DF[1,])) DF = DF[-1, ] Try this: colnames(DF) = DF[1, ] # the first row will be the header DF = DF[-1, ] # removing the

Javascript: Dynamic function names [duplicate]

别说谁变了你拦得住时间么 提交于 2019-11-28 10:54:51
This question already has an answer here: Dynamic function name in javascript? 20 answers How to create a function with a dynamic name? Something like: function create_function(name){ new Function(name, 'console.log("hello world")'); } create_function('example'); example(); // --> 'hello world' Also the function should be a Function Object so I can modify the prototype of the object. window.example = function () { alert('hello world') } example(); or name = 'example'; window[name] = function () { ... } ... or window[name] = new Function('alert("hello world")') I've been playing around with

R: losing column names when adding rows to an empty data frame

筅森魡賤 提交于 2019-11-28 05:37:39
I am just starting with R and encountered a strange behaviour: when inserting the first row in an empty data frame, the original column names get lost. example: a<-data.frame(one = numeric(0), two = numeric(0)) a #[1] one two #<0 rows> (or 0-length row.names) names(a) #[1] "one" "two" a<-rbind(a, c(5,6)) a # X5 X6 #1 5 6 names(a) #[1] "X5" "X6" As you can see, the column names one and two were replaced by X5 and X6 . Could somebody please tell me why this happens and is there a right way to do this without losing column names? A shotgun solution would be to save the names in an auxiliary

Mass produce JTables

本小妞迷上赌 提交于 2019-11-28 02:27:39
I want to make 25 JTables. I generate the table names by doing: for(int i=0; i < 26; i++) { TableNames[i] = "Table" + i + ""; ... How can I go about using these String names in the array as the new JTable names? i.e. TableNames[i] = new JTable(model){ ... Instead of an array, consider using a List<JTable> or List<TableModel> . Pass the name to the table's constructor or factory method. The example below uses the Component 's name, but a JComponent 's client property may be more versatile. Update : The revised Java 8 example below illustrates how to add new tables dynamically. import java.awt