Why not read in the file and then change that column
from a character to a numeric?
Simple-minded example"
aa <- c("$.50" ,"$.5", "$.25" )
bb <- gsub("\\$", "", aa) # Drop the $ symbol
cc <- as.numeric(bb) # convert character to numeric.
cc
--- mrafi <[EMAIL PROTECTED]> wrote:
>
> yeah...i'd
yeah..that worked for me...thanks...!!
jholtman wrote:
>
> Here is a way of doing it:
>
>> x <- "1 2 $.05
> + 3 4 $1.05
> + 5 6 $23.56"
>> x <- read.table(textConnection(x))
>> x
> V1 V2 V3
> 1 1 2 $.05
> 2 3 4 $1.05
> 3 5 6 $23.56
>> # delete "$" and convert to numeric
>> x$conv
Hi,
I have a tempoary fix but I think there can be a better way (R way) to solve
this.
If you have a unix account you can do it this way.
$ vi filename
For command prompt press Esc
: s/\$//g
Otherwise you can replace $ sign with a peculiar number say ''
:s/\$//g
This substitutes $ s
yeah...i'd have done that but it is a 20 mb csv file...and then there are
other columns of data also..which could be distorted by this...
r_a_mueller wrote:
>
> Am Mittwoch, 2. Januar 2008 14:14 schrieb mrafi:
>> hello respected ppl...
>> am a engg. student...i was trying to use R in statistica
Here is a way of doing it:
> x <- "1 2 $.05
+ 3 4 $1.05
+ 5 6 $23.56"
> x <- read.table(textConnection(x))
> x
V1 V2 V3
1 1 2 $.05
2 3 4 $1.05
3 5 6 $23.56
> # delete "$" and convert to numeric
> x$converted <- as.numeric(sub("\\$", "", as.character(x$V3)))
> str(x)
'data.frame':
Am Mittwoch, 2. Januar 2008 14:14 schrieb mrafi:
> hello respected ppl...
> am a engg. student...i was trying to use R in statistical calculations
> now the problem is..i imported a huge tsv file onto R...it has a column
csv?
> which gives cost...and it has "$" with each numerical value in this
> c
hello respected ppl...
am a engg. student...i was trying to use R in statistical calculations
now the problem is..i imported a huge tsv file onto R...it has a column
which gives cost...and it has "$" with each numerical value in this
column...it is something like this..$.05,$.1,$.075...and so on..
7 matches
Mail list logo