names

matrix and table names / dimnames

て烟熏妆下的殇ゞ 提交于 2019-12-01 00:48:59
Probably my question is answered somewhere but I have used my searching resources before asking. I have a sample table in R : munic Gender Mun1 Mun2 female 146980 285797 male 140436 270084 When I use dimnames(sample) I get the following: > dimnames(sample) $Gender [1] "female" "male" $munic [1] "Mun1" "Mun2" And I want to create one exactly alike. So I do the following: Mat<-matrix(c(148470,24721,22829,24777,26137,43169,49613,40406,48337,34296,19492,+ 176712, 27406, 23010, 25487, 27064, 48349, 52140, 44335, 50908, 35814, 18825), nrow=2) colnames(Mat) <-c("mun_5","mun_1","mun_2","mun_3","mun_4"

matrix and table names / dimnames

三世轮回 提交于 2019-11-30 18:32:21
问题 Probably my question is answered somewhere but I have used my searching resources before asking. I have a sample table in R : munic Gender Mun1 Mun2 female 146980 285797 male 140436 270084 When I use dimnames(sample) I get the following: > dimnames(sample) $Gender [1] "female" "male" $munic [1] "Mun1" "Mun2" And I want to create one exactly alike. So I do the following: Mat<-matrix(c(148470,24721,22829,24777,26137,43169,49613,40406,48337,34296,19492,+ 176712, 27406, 23010, 25487, 27064, 48349

refer to range of columns by name in R

牧云@^-^@ 提交于 2019-11-30 15:30:10
I need help with something that might be fairly simple in R. I want to refer to a range of columns in a data frame (e.g., extracting a few select variables). However, I don't know their column numbers. Normally, if I wanted to extract columns 4-10 i would say mydata[,4:10]. However, given that I don't know the column numbers, I would want to refer to them by name. Is there an easy way to do this? in sas or spss it is fairly easy to refer to a range of variables by name. Alternatively, is there an easy way to figure out which column number corresponds to a variable name in R? Matt_J A column

reading a csv file with repeated row names in R

不问归期 提交于 2019-11-30 08:03:56
I am trying to read a csv file with repeated row names but could not. The error message I am getting is Error in read.table(file = file, header = header, sep = sep, quote = quote, : duplicate 'row.names' are not allowed. The code I am using is: S1N657 <- read.csv("S1N657.csv",header=T,fill=T,col.names=c("dam","anim","temp")) An example of my data is given below: did <- c("1N657","1N657","1N657","1N657","1N657","1N657","1N657","1N657","1N657","1N657") aid <- c(101,102,103,104,105,106,107,108,109,110) temp <- c(36,38,37,39,35,37,36,34,39,38) data <- cbind(did,aid,temp) Any help will be

3 Dimensional Array Names in R

时光毁灭记忆、已成空白 提交于 2019-11-30 07:23:16
问题 In the 3 Dimensional array bellow : ar <- array(someData, c(5, 5, 5)); rownames(ar) <- ...; #to set up row names colnames(ar) <- ...; #to set up col names How can i set the third dimension names ? 回答1: You can either set the dimnames argument when defining the array: ar <- array(data = 1:27, dim = c(3, 3, 3), dimnames = list(c("a", "b", "c"), c("d", "e", "f"), c("g", "h", "i"))) and/or you can set the dimnames of the third dimension like so: dimnames(ar)[[3]] <- c("G", "H", "I") 回答2: Still

Naming list elements in R

扶醉桌前 提交于 2019-11-30 03:48:41
I've been doing some work with some large, complex lists lately and I've seen some behaviour which was surprising (to me, at least), mainly to do with assigning names to a list. A simple example: Fil <- list( a = list(A=seq(1, 5, 1), B=rnorm(5), C=runif(5)), b = list(A="Cat", B=c("Dog", "Bird"), C=list("Squirrel", "Cheetah", "Lion")), c = list(A=rep(TRUE, 5), B=rep(FALSE, 5), C=rep(NA, 5))) filList <- list() for(i in 1:3){ filList[i] <- Fil[i] names(filList)[i] <- names(Fil[i]) } identical(Fil,filList) [1] TRUE but: for(i in 1:3){ filList[i] <- Fil[i] names(filList[i]) <- names(Fil[i]) }

Checking if a domain name is registered

只愿长相守 提交于 2019-11-30 03:38:27
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? Thomas "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... surprise... phpwhois . Mike Nott has created a simple PHP class that allows you to query the who.is

Get the column names of a python numpy ndarray

╄→гoц情女王★ 提交于 2019-11-30 00:19:51
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 line and parse it as a separate operation, but that doesn't seem very efficient or elegant. Try: myData

reading a csv file with repeated row names in R

混江龙づ霸主 提交于 2019-11-29 11:01:24
问题 I am trying to read a csv file with repeated row names but could not. The error message I am getting is Error in read.table(file = file, header = header, sep = sep, quote = quote, : duplicate 'row.names' are not allowed. The code I am using is: S1N657 <- read.csv("S1N657.csv",header=T,fill=T,col.names=c("dam","anim","temp")) An example of my data is given below: did <- c("1N657","1N657","1N657","1N657","1N657","1N657","1N657","1N657","1N657","1N657") aid <- c(101,102,103,104,105,106,107,108

3 Dimensional Array Names in R

天涯浪子 提交于 2019-11-29 05:35:47
In the 3 Dimensional array bellow : ar <- array(someData, c(5, 5, 5)); rownames(ar) <- ...; #to set up row names colnames(ar) <- ...; #to set up col names How can i set the third dimension names ? You can either set the dimnames argument when defining the array: ar <- array(data = 1:27, dim = c(3, 3, 3), dimnames = list(c("a", "b", "c"), c("d", "e", "f"), c("g", "h", "i"))) and/or you can set the dimnames of the third dimension like so: dimnames(ar)[[3]] <- c("G", "H", "I") Still starting in R but I found this way that may be useful for large multidimensional array. Instead of naming each of