[R] NULL column
arun
smartpink111 at yahoo.com
Thu Aug 9 01:51:19 CEST 2012
Hi Silvano,
You can save the data as "filename.txt" and then call read.table()
For example,
I saved your data:
#################################################
beta0 beta1 pvalor Crom
rs17 158.5980 12.252462 9.083193e-135 1
rs46 163.3730 3.304276 3.279925e-06 1
rs63 162.7924 2.084678 5.023893e-06 1
rs24 162.4252 1.837208 5.509042e-06 1
##################################################
as "dat11.txt"
dat1<-read.table("dat11.txt",sep="",header=TRUE)
dat2<-data.frame(new=rownames(dat1),dat1)
rownames(dat2)<-1:nrow(dat2)
dat2
new beta0 beta1 pvalor Crom
1 rs17 158.5980 12.252462 9.083193e-135 1
2 rs46 163.3730 3.304276 3.279925e-06 1
3 rs63 162.7924 2.084678 5.023893e-06 1
4 rs24 162.4252 1.837208 5.509042e-06 1
You can also save it as "filename.csv" and use read.csv() or read.delim()
dat1<-read.csv("dat11.csv",sep="",header=TRUE)
Hope it helps.
A.K.
----- Original Message -----
From: Silvano Cesar da Costa <silvano at uel.br>
To: arun <smartpink111 at yahoo.com>
Cc:
Sent: Wednesday, August 8, 2012 7:30 PM
Subject: Re: [R] NULL column
Hi Arun,
it worked perfectly.
The only problem is that the data set is great to put in the
read.table(text=" ")
But it worked.
Thank you
> HI,
> Try this:
>
>
> dat1<-read.table(text="
> beta0 beta1 pvalor Crom
> rs17 158.5980 12.252462 9.083193e-135 1
> rs46 163.3730 3.304276 3.279925e-06 1
> rs63 162.7924 2.084678 5.023893e-06 1
> rs24 162.4252 1.837208 5.509042e-06 1
> ",sep="",header=TRUE)
> dat2<-data.frame(new=rownames(dat1),dat1)
>> rownames(dat2)<-1:nrow(dat2)
>> dat2
> # new beta0 beta1 pvalor Crom
> #1 rs17 158.5980 12.252462 9.083193e-135 1
> #2 rs46 163.3730 3.304276 3.279925e-06 1
> #3 rs63 162.7924 2.084678 5.023893e-06 1
> #4 rs24 162.4252 1.837208 5.509042e-06 1
>
>
> A.K.
>
>
>
> ----- Original Message -----
> From: Silvano Cesar da Costa <silvano at uel.br>
> To: r-help at r-project.org
> Cc:
> Sent: Wednesday, August 8, 2012 3:22 PM
> Subject: [R] NULL column
>
> Hi,
>
> I have a dataset where the first column has no name.
>
> I would like to assign a name to this column to be able to use it
>
> something like:
>
> Cap <- NULL
>
>
> How can I do this?
>
> beta0 beta1 pvalor Crom
> rs17 158.5980 12.252462 9.083193e-135 1
> rs46 163.3730 3.304276 3.279925e-06 1
> rs63 162.7924 2.084678 5.023893e-06 1
> rs24 162.4252 1.837208 5.509042e-06 1
>
>
> How can I do this?
>
>
> Thanks,
>
>
> ---------------------------------------------
> Silvano Cesar da Costa
>
> Universidade Estadual de Londrina
> Centro de Ciências Exatas
> Departamento de Estatística
>
> Fone: (43) 3371-4346
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
---------------------------------------------
Silvano Cesar da Costa
Universidade Estadual de Londrina
Centro de Ciências Exatas
Departamento de Estatística
Fone: (43) 3371-4346
----------------------------
More information about the R-help
mailing list