Figured it out. Solution:
dat=read.csv(file_path, header=F)
> dat
  V1         V2        V3       V4      V5         V6        V7
V8        V9        V10        V11        V12        V13       V14
V15         V16       V17       V18         V19        V20
1  0 -0.2404324 0.3554681 -0.21147 1.18128 -0.2279752 0.7483484 -1.049239
0.5660589 -0.1840771 -0.6933892 -0.4749619 -0.5575557 0.3741988 0.5606208
-0.06091273 0.6453374 0.3537118 -0.09991461 -0.3207118
        V21       V22       V23       V24       V25       V26
V27        V28       V29        V30        V31       V32        V33
V34        V35       V36        V37        V38       V39
1 0.3321949 0.5137949 0.2281249 0.1412501 0.8793599 0.7216529 -1.147237
-0.0871542 0.3021812 0.05944923 -0.2407231 0.3589717 -0.4295433 -0.07399785
-0.1088064 0.6161071 -0.2026699 -0.2004506 0.1542169
          V40      V41        V42        V43       V44        V45
V46        V47        V48         V49       V50      V51       V52
V53        V54       V55        V56        V57        V58
1 -0.06293466 1.160775 -0.1009804 -0.4574294 0.1289299 -0.1434428 -1.090505
-0.2702305 -0.4381005 -0.06666691 0.1836706 0.728843 0.2219863 -0.7939716
-0.2580837 0.4604682 -0.6085527 -0.1102456 -0.2470147
         V59        V60      V61        V62       V63        V64
V65      V66      V67        V68       V69       V70       V71
V72        V73       V74       V75        V76        V77
1 -0.1374674 0.05771337 0.615591 -0.2103958 0.3729799 -0.7636618 1.222489
1.175414 1.349652 -0.0653956 0.4461732 0.7385489 0.4267874 -0.4099944
-0.4456437 0.1310654 0.5912901 0.03645256 -0.1760742
        V78       V79       V80

Thanks,
Ben

On Thu, Oct 27, 2011 at 1:12 PM, Justin Haynes <jto...@gmail.com> wrote:

> Id look at the actual csv file.  I assume it has the X there also.
> sounds like a good candidate for some data munging tools first before
> you bring it into R.  also ?str of the data would be helpful. My first
> guess is those are all being read as column names.  Were they data in
> the data.frame dat the should be quoted:
>
> > dat<-c('X0.0','X.0.24','X0.35','X.0.211')
> > dat
> [1] "X0.0"    "X.0.24"  "X0.35"   "X.0.211"
>
> versus:
>
> > names(dat)<-c('col_one','X.0.44',0.65,'last_col')
> > dat
>  col_one    X.0.44      0.65  last_col
>   "X0.0"  "X.0.24"   "X0.35" "X.0.211"
>
>
>
> However, if you want to use R to clean it up, I'd use the stringr package.
>
> > library(stringr)
>
> > dat<-str_replace(dat,'X.0.','-0.')
> > dat
> [1] "X0.0"   "-0.24"  "X0.35"  "-0.211"
> > dat<-str_replace(dat,'X','')
> > dat
> [1] "0.0"    "-0.24"  "0.35"   "-0.211"
> > dat<-as.numeric(dat)
> > dat
> [1]  0.000 -0.240  0.350 -0.211
> >
>
> hope that helps,
>
> Justin
>
>
> On Thu, Oct 27, 2011 at 11:47 AM, Ben quant <ccqu...@gmail.com> wrote:
> > Hello,
> >
> > Why do I get preceding "X." (that is a and X followed by a period) for
> > negative numbers and an "X" for positive numbers when I read a csv file?
> Am
> > I stuck with this? If so, how do I convert it to normal numbers?
> >
> > dat=read.csv(file_path)
> >
> >> dat
> >  [1] X0.0               X.0.240432350374   X0.355468069625
> > X.0.211469972378   X1.1812797415      X.0.227975150826   X0.74834842067
> > X.1.04923922494    X0.566058942902    X.0.184077147931
> >  [11] X.0.693389240029   X.0.474961946724   X.0.557555716654
> > X0.374198813899    X0.560620781209    X.0.0609127295732  X0.645337364133
> > X0.353711785227    X.0.0999146114953  X.0.320711825714
> >  [21] X0.332194935294    X0.513794862516    X0.228124868198
> > X0.141250108666    X0.879359879038    X0.721652892103    X.1.14723732497
> > X.0.0871541975062  X0.302181204959    X0.0594492294833
> >  [31] X.0.240723094394   X0.358971714966    X.0.42954330242
> > X.0.0739978455876  X.0.108806367787   X0.616107131373    X.0.202669947993
> > X.0.200450609711   X0.15421692014     X.0.0629346641528
> >  [41] X1.16077454571     X.0.100980386545   X.0.457429357325
> > X0.128929934631    X.0.143442822494   X.1.09050490567    X.0.270230489547
> > X.0.438100470791   X.0.0666669111547  X0.18367056566
> >  [51] X0.728842996177    X0.221986311856    X.0.793971624503
> > X.0.258083713185   X0.460468157809    X.0.608552686527   X.0.11024558138
> > X.0.247014689522   X.0.137467423146   X0.0577133684917
> >  [61] X0.615590960098    X.0.210395786553   X0.372979876654
> > X.0.763661795812   X1.22248872639     X1.17541364078     X1.34965201031
> > X.0.0653956005331  X0.446173249776    X0.738548926264
> >  [71] X0.426787360705    X.0.409994430265   X.0.445643675958   ....etc...
> >
> > Thanks
> >
> > ben
> >
> >        [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@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.
> >
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to