[R] ASCII values to Decimal
Bansal, Vikas
vikas.bansal at kcl.ac.uk
Fri Jul 8 16:41:43 CEST 2011
Dear all,
I have a file and I am using a code-
df=read.table("Case2.pileup",fill=T,sep="\t",colClasses = "character")
to create a data frame that is df.
now in 4th column I have ASCII values which I want to convert in decimal values.the data frame is like this-
V1 V2 V3 V4
9 2 ., a\
9 2 .$, a`
13 1 , a
13 1 , a
13 1 , a
13 1 , a
13 1 , `
13 1 , ^
13 1 , a
13 1 ,$ a
I am using this code to convert it-
as.numeric(charToRaw(df[,4]))
it is showing this error-
Warning message:
In charToRaw(df[, 4]) : argument should be a character vector of length 1
all but the first element will be ignored
and it is converting only the value in first row.How can I do this for all rows in my data frame.
Please help me.I am new user for R.I will be very thankful to you.
Thanking you,
Warm Regards
Vikas Bansal
Msc Bioinformatics
Kings College London
More information about the R-help
mailing list