Displaying 20 results from an estimated 70000 matches similar to: "read.table question #only need to change column names"
2011 Mar 16
2
Need to abstract changing name of column within loop
Hi,
I'm struggling to figure out the way to change the name of a column
from within a loop. The problem is I can't refer to the object by its
actual variable name, since that will change each time through the
loop. My xts object is A.
> head(A)
A.Open A.High A.Low A.Close A.Volume A.Adjusted A.Adjusted.1
2007-01-03 34.99 35.48 34.05 34.30 2574600 34.30
2006 Jan 20
4
read.table with ":" in column names (PR#8511)
Full_Name: emiel ver loren
Version: 2.2.0
OS: Windows XP
Submission from: (NULL) (145.117.31.248)
Dear R-community and developers,
I have been trying to read in a tab delimeted file where the column names and
the row names are of the form "GO:0000051" (gene ontology IDs). When using:
> gomat<-read.table("test.txt")
> colnames(gomat)[1]
[1] "GO.0000051"
2010 Jun 09
2
Change the name of one column ONLY
Hi all,
I have a very simple problem that I cannot seem to find the answer to. Consider the following toy dataset:
x <- read.table(textConnection("V1 apples bananas cherries
indv.1 7 8 4 3
indv.2 7 7 4 9"), header = TRUE)
How would I change the column name of ONLY the first column, not the others? Surely I should not have to re-specify the names of ALL the columns -- e.g.,
2010 Aug 05
2
a question about 'read.table' with or without 'read.table'.(urgent)
Hi, I've got a quite tricky question.
I have a txt file, named 'temp.txt', as the following:
snp1 snp2 snp3
AA 00 00
GG GG 00
00 AA 00
I want to read the file into R.
1) when I use 'read.table' without 'header=T' option,
> temp <- read.table('temp.txt')
# I got
> temp
V1
2010 Mar 18
1
How to read.table with “Hebrew” column names (in R)?
(I am reposting this question after a few months without a solution...)
Hi all,
I am trying to read a .txt file, with Hebrew column names, but without
success.
I uploaded an example file to: http://www.talgalili.com/files/aa.txt
And tried the command:
read.table("http://www.talgalili.com/files/aa.txt", header = T, sep = "\t")
This returns me with:
X.....ª X...ª......
2008 Jul 10
2
princomp loading help
Dear all,
When I print out princomp's loading outputs, there is alwasy a section for "SS loading", "Proportional Var" and "Cumulative Var". Anybody can tell what they are for? Or anyone can direct me to some reference to read about?
Any help will be highly appricated.
Hongsheng
[[alternative HTML version deleted]]
2010 Jan 01
4
How to use read.table with Hebrew column names ?
Hello dear R help group,
I am trying to read a .txt file, with Hebrew column names, while keeping the
column names looking well in R - but without success.
I uploaded an example file to:
http://www.talgalili.com/files/aa.txt
And am trying the command:
read.table("http://www.talgalili.com/files/aa.txt", header = T, sep = "\t")
This returns me with:
X.....ª X...ª......
2009 May 31
2
renaming column names
I am trying to rename the column names of a data frame called "data". It has
177 columns. I have used :
colnames(data) <- a
where a is a vector with 177 character names.
I don''t get any error message, but the column names don''t change because
when I then type :
colnames(data)
I get the same set of names as before, so the assignment doesnt seem to have
2010 Sep 01
2
getting column names of row-by-row sorted matrix
Hi folks,
I want to sort a matrix row-by-row and create a new matrix that contains the corresponding colnames of the original matrix.
E.g.
> set.seed(123)
> a <- matrix(rnorm(20), ncol=4); colnames(a) <- c("A","B","C","D")
> a
A B C D
[1,] -0.56047565 1.7150650 1.2240818 1.7869131
[2,]
2009 Mar 27
2
adding matrices with common column names
folks,
if i have three matrices, a, b, cc with some colnames in common, and i
want to create a matrix which consists of the common columns added up,
and the other columns tacked on, what's a good way to do it? i've got
the following roundabout code for two matrices, but if the number of
matrices increases, then i'm a bit stymied.
> a <- matrix(1:20,ncol=4); colnames(a) <-
2010 Jul 09
2
select columns from vector of column names
Hi
I want to extract columns from a data frame using a vector with the desired
column names.
This short example uses the select argument in the subset function to
accomplish what I am trying to do. Is there a better solution?
#names of desired columns
colnames <- c("col1","col3")
#my data
data <-
2009 Oct 27
2
column names of a correlation matrix
Hi! All,
I am working on a correlation matrix of 4217x4217 named 'cor_expN'. I wish
to obtain pairs with highest correlation values. So, I did this
> b=matrix(data=NA,nrow=4217,ncol=1)
> rownames(b)=rownames(cor_expN)
> for(i in 1:4217){b[i,]=max(cor_expN[i,])}
> head(b)
[,1]
aaeA_b3241_14 0.7181912
aaeB_b3240_15 0.7513084
aaeR_b3243_15 0.7681684
2011 Sep 20
2
How to transfer variable names to column names?
Hello R users,
I have a set of data frames for which I am tallying row numbers, as shown below.
> nrow(mC_Explant)
[1] 14480
> nrow(mC_Callus)
[1] 23320
> nrow(mC_RegenPlant)
[1] 8108
etc.
I want to create a new data frame which has the variable names as column headings, and then a single row with the nrow tallies. My first step was this:
dfIntron <- c(nrow(mC_Explant),
2011 Apr 28
2
changing a specific column name
Hi,
Can someone please tell me how to change the column name of a specific
column. How do I change the name of the column 'Species'?
Thanks in advance
d <- iris
colnames(d)
[1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
ind <- which(names(d)=='Species')
ind
[1] 5
colnames(d[ind])
[1]
2007 Sep 16
1
Putting column names in some automated way
Dear all,
I have following codes:
colnames(data) = c("var", "var", "var")
i = c(1,2,3)
Now I want construct a "for" loop starting from 1 to 3 to give the new names of columns for dataframe "data" like below
colnames(data)
> c("var1", "var2", "var3")
Definitely I could do this manually, however I want to put
2008 Jul 01
3
Change name of a specific column of a data frame
Hi,
Sorry for the simple question. Is there a way to change the name of only one
column of an existing data frame?
I know colnames allows you to set the name of all the columns, but only one
column in the middle of my data frame needs a new name.
Thanks,
-Nina
2010 Jul 19
3
concatenating column names in a loop
Hi all,
I am trying to concatenate words together to create new column names, using a
loop.
Please consider the following toy example:
x <- matrix(nrow = 1, ncol = 3)
colnames(x) <- c("a", "b", "c")
x[1,1] <- "1"
x[1,2] <- "2"
x[1,3] <- "3"
I would like to create a new matrix with column names based on the column names
2010 Aug 05
1
difficulties with read.table applied to files from URL
Hello,
I am using read.table to read files directly from a public ftp site. I have
a general list of files that may or may not exist in the ftp directory, but
my hope was that R would read the file if it existed and ignored it if it
didn't exist and move on to the next one. However, when R arrives at a file
that does not exist I get the error message "Error in file(file, "rt") :
2005 Nov 25
1
read.table without sep
Hello all,
I have a data file table.txt which i have attached. I am trying to pass the
columns as arguments to a function "totnorm" where i am displaying a total
normalization plot. The function is given below:
totnorm<-function(x,y){scale<-sum(x)/sum(y);xlab<-colnames(x);ylab<-colnames(y);x1<-x[[1]];y1<-scale*y[[1]];plot(x1,y1,xlab=xlab,ylab=ylab,col=6,
col.lab=4);}
2005 Nov 25
1
read.table without sep
Hello all,
I have a data file table.txt which i have attached. I am trying to pass the
columns as arguments to a function "totnorm" where i am displaying a total
normalization plot. The function is given below:
totnorm<-function(x,y){scale<-sum(x)/sum(y);xlab<-colnames(x);ylab<-colnames(y);x1<-x[[1]];y1<-scale*y[[1]];plot(x1,y1,xlab=xlab,ylab=ylab,col=6,
col.lab=4);}