[R] Problem to read non-standard csv file

Roberto rmoscetti at unitus.it
Fri Oct 12 22:20:57 CEST 2012


arun kirshna wrote
> Hi,
> Try this:
> tab1<-read.csv2("Specimen_RawData_1.csv",sep="\t",nrows=-1)
> tab2<-as.data.frame(sapply(tab1,function(x)
> gsub("[,]",".",x)),stringsAsFactors=FALSE)
> tab3<-tab2[-1,]
> tab3[]<-sapply(tab3,as.numeric)
>  row.names(tab3)<-1:nrow(tab3)
>  head(tab3)
> #  Carico.compressione Corsa.compressione Tempo
> Deformazione.in.compressione
> #1             0.16648            0.00000 0.000                     
> 0.00000
> #2             0.16622            0.00000 0.002                     
> 0.00000
> #3             0.16585            0.00000 0.004                     
> 0.00000
> #4             3.96132            0.14063 0.104                     
> 0.01078
> #5            20.67722            0.31937 0.204                     
> 0.02449
> #6            39.88020            0.49078 0.304                     
> 0.03763
>  str(tab3)
> #'data.frame':	81 obs. of  4 variables:
> # $ Carico.compressione         : num  0.166 0.166 0.166 3.961 20.677 ...
> # $ Corsa.compressione          : num  0 0 0 0.141 0.319 ...
> # $ Tempo                       : num  0 0.002 0.004 0.104 0.204 0.304
> 0.404 0.504 0.604 0.704 ...
> # $ Deformazione.in.compressione: num  0 0 0 0.0108 0.0245 ...
> A.K.

Thank you very much.
It work very well!

Best,
Roberto




--
View this message in context: http://r.789695.n4.nabble.com/Problem-to-read-non-standard-csv-file-tp4646018p4646036.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list