Re: [R] help with replacing all comma in a data frame with a dot

2008-01-23 Thread John Kane
I think this will do it. mysub <- function(x) {sub(",",".",x)} mydata <- (apply(kk, 2, mysub )) kk1 <- data.frame(apply(mydata, 2, as.numeric)) --- Tom Cohen <[EMAIL PROTECTED]> wrote: > Dear list, > > I have imported a spss data file in R, where a > comma is used to separate the decima

Re: [R] help with replacing all comma in a data frame with a dot

2008-01-23 Thread Peter Dalgaard
Tom Cohen wrote: > Dear list, > > I have imported a spss data file in R, where a comma is used to separate > the decimal numbers, e.g. 3,567 instead of 3.567 as in R. How can I replace > the comma with a dot for all values in the data frame > How did you read the data in the first place

Re: [R] help with replacing all comma in a data frame with a dot

2008-01-23 Thread Henrique Dallazuanna
apply(apply(df, 2, gsub, patt=",", replace="."), 2, as.numeric) or you can read the data file with read.table using dec argument: df <- read.table('clipboard', dec=",", header=T, row.names=1) On 23/01/2008, Tom Cohen <[EMAIL PROTECTED]> wrote: > Dear list, > > I have imported a spss data fi

[R] help with replacing all comma in a data frame with a dot

2008-01-23 Thread Tom Cohen
Dear list, I have imported a spss data file in R, where a comma is used to separate the decimal numbers, e.g. 3,567 instead of 3.567 as in R. How can I replace the comma with a dot for all values in the data frame >kk ab c d ef