Questions tagged [names]

"names" (plural) is an attribute of some R objects in the R language

In the scientific software R for statistical computing and graphics, "names" is an attribute of some data objects, like vectors (including lists) and data frames. See ?names for details.

873 questions
14
votes
1 answer

Adding two vectors by names

I have two named vectors v1 <- 1:4 v2 <- 3:5 names(v1) <- c("a", "b", "c", "d") names(v2) <- c("c", "e", "d") I want to add them up by the names, i.e. the expected result is > v3 a b c d e 1 2 6 9 4 Is there a way to programmatically do this…
Ricky
  • 4,616
  • 6
  • 42
  • 72
14
votes
4 answers

Checking if a domain name is registered

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?
Evan Fosmark
  • 98,895
  • 36
  • 105
  • 117
14
votes
1 answer

What's the difference between Name and CanonicalName?

What is the difference between Java's Class.getName() and Class.getCanonicalName()?
durron597
  • 31,968
  • 17
  • 99
  • 158
14
votes
4 answers

PHP Regex for human names

I've run into a bit of a problem with a Regex I'm using for humans names. $rexName = '/^[a-z' -]$/i'; Suppose a user with the name Jürgen wishes to register? Or Böb? That's pretty commonplace in Europe. Is there a special notation for this? EDIT:,…
KdgDev
  • 14,299
  • 46
  • 120
  • 156
13
votes
6 answers

How to extract the last digits of strings using regular expressions?

I have a bunch of colnames L_1_3 L_2_23 L_3_91 L_3_16 I want to replace these colnames with new names using the last digits following the _ like this: 3 23 91 16 I've tried colnames(X) <- gsub("L_\\d\\d_", "", colnames(X)) which works for strings…
Drew
  • 563
  • 2
  • 8
13
votes
4 answers

R: access field values

I would like to know how I can access the individual fields contained in an R object. Or, more precisely, how to get R to tell me how. For example, if I run the following code: dx.ct <- ur.df(dat1[,'dx'], lags=3, type='trend') summary(dx.ct) then I…
Karl
  • 5,573
  • 8
  • 50
  • 73
12
votes
1 answer

'default' as a variable name

While debugging some code, I came across an array named default. I thought that keywords were not allowed as variable names. #include "stdafx.h" #include int main() { int default = 5; printf("%d\n", default); return 0; } Now the above…
Agnel Kurian
  • 57,975
  • 43
  • 146
  • 217
11
votes
3 answers

How can I subscript names in a table from kable()?

Given a data.frame A, how can I use subscripted rows and columns names? Eventually I want produce a table through kable() in rmarkdown (output: word document). A <- data.frame(round(replicate(3, runif(2)),2)) rownames(A) <- c("Hola123",…
AJMA
  • 1,134
  • 2
  • 13
  • 28
11
votes
2 answers

Naming array dimensions gives error: length of 'dimnames' not equal to array extent

This is my first time using a 3 dimensional array and I am having problems about naming the third dimension. ReplicateData <- array(0, c(240, 500, 5), dimnames=list(NULL, NULL, c("Returns", "Replicates", "Asset Class"))) I am getting the…
ProbablePattern
  • 703
  • 2
  • 7
  • 17
11
votes
1 answer

Go library package names

I have some questions on package naming for external Go libraries. I am interested if using generic names like "text" is considered a good practice? Having in mind that I cannot declare a "nested package" and that the library I am building deals…
user1305056
11
votes
2 answers

Replace data.frame column names with a string in corresponding lookup table

I have the following data.frame: set.seed(126) df <- data.frame(a=sample(c(1:100, NA), 10), b=sample(1:100, 10), c=sample(1:100, 10), d = c(1:10)) a b c d 1 18 27 53 1 2 44 16 66 2 3 58 47 3 3 ... And the following lookup…
gh0strider18
  • 1,140
  • 3
  • 13
  • 23
11
votes
10 answers

What is the best practice for using "get" in method names?

I've noticed in many places in Java (C# included), that many "getter" methods are prefixed with "get" while many other aren't. I never noticed any kind of pattern Sun seems to be following. What are some guidelines or rules for using "get" in getter…
mcjabberz
  • 9,788
  • 10
  • 36
  • 38
10
votes
3 answers

MySQL retrieve column names where datatype == X

I need to write some code that applies to only certain fields within our database. Specifically I'm looking for any field in all tables of a single database that are of type DECIMAL(12,5); If it's of any help, all of our decimal fields are prefixed…
Zetaphor
  • 504
  • 10
  • 24
10
votes
1 answer

Different parameter name in function prototype

I found a program which uses different parameters in function prototyping and declaring, so I made a basic program. #include using namespace std; void add(int a, int b); int main() { add(3,4); } void add(int c, int d){ int e =…
Athul
  • 429
  • 2
  • 5
  • 19
10
votes
5 answers

Concatenating Variable Names in C?

Is it possible to concatenate variable names in C? Specifically, I have a struct that contains 6 similar variables in it called class1, class2, class3, etc. I want to run through a for loop to assign each variable a value, but I can't see how to do…
Tyler Treat
  • 14,640
  • 15
  • 80
  • 115
1 2
3
58 59