[R] Reading Data

arun smartpink111 at yahoo.com
Tue Apr 9 07:40:54 CEST 2013


Hi,

I tried to read your data from the image:
OPENCUT<- read.table("OpenCut.dat",header=TRUE,sep="\t")
OPENCUT
          FC     LC  SR  DM
1  400030.34 1323.5   0 400
2   12680.13    2.5   0 180
3  472272.75 2004.7   3 300
4  332978.03 1301.3 106 180
5   98654.20  295.0   0 180
6   68142.05  259.9  69 125
7  178433.11  425.0  49 180
8   96765.83  635.5  12 180
9  204808.90  640.4   0 400
10 151760.20  357.0   0 180
11  91330.42  173.6   6 180
12  93154.33  197.5  16 125
13 121030.15  203.0  30 125
14  60132.75  160.0  26 125
15  32233.78   69.0   8  90
16  44445.13  137.0   0 125
17 160791.82 1335.0   0 180
18  62531.76   80.5  21 180



str(OPENCUT)
#'data.frame':    18 obs. of  4 variables:
# $ FC: num  400030 12680 472273 332978 98654 ...
# $ LC: num  1323.5 2.5 2004.7 1301.3 295 ...
# $ SR: int  0 0 3 106 0 69 49 12 0 0 ...
# $ DM: int  400 180 300 180 180 125 180 180 400 180 ...

You didn't mention whether you attach(OPENCUT) or not. 


If you didn't attach the data:

 OPENCUT$FC
# [1] 400030.34  12680.13 472272.75 332978.03  98654.20  68142.05 178433.11
 #[8]  96765.83 204808.90 151760.20  91330.42  93154.33 121030.15  60132.75
#[15]  32233.78  44445.13 160791.82  62531.76
 OPENCUT$LC
# [1] 1323.5    2.5 2004.7 1301.3  295.0  259.9  425.0  635.5  640.4  357.0
#[11]  173.6  197.5  203.0  160.0   69.0  137.0 1335.0   80.5
 OPENCUT$SR
# [1]   0   0   3 106   0  69  49  12   0   0   6  16  30  26   8   0   0  21
 OPENCUT$DM
# [1] 400 180 300 180 180 125 180 180 400 180 180 125 125 125  90 125 180 180
 OPENCUT[,1]
# [1] 400030.34  12680.13 472272.75 332978.03  98654.20  68142.05 178433.11
 #[8]  96765.83 204808.90 151760.20  91330.42  93154.33 121030.15  60132.75
#[15]  32233.78  44445.13 160791.82  62531.76


attach(OPENCUT) #this I won't recommend 
 FC
# [1] 400030.34  12680.13 472272.75 332978.03  98654.20  68142.05 178433.11
 #[8]  96765.83 204808.90 151760.20  91330.42  93154.33 121030.15  60132.75
#[15]  32233.78  44445.13 160791.82  62531.76
 LC
# [1] 1323.5    2.5 2004.7 1301.3  295.0  259.9  425.0  635.5  640.4  357.0
#[11]  173.6  197.5  203.0  160.0   69.0  137.0 1335.0   80.5


SR
# [1]   0   0   3 106   0  69  49  12   0   0   6  16  30  26   8   0   0  21
 DM
# [1] 400 180 300 180 180 125 180 180 400 180 180 125 125 125  90 125 180 180



Not sure how you got that errors.  It would be better if you dput(OPENCUT).


A.K.




Hi, 

I know there are several similar post, but I really have troubles reading a simple .dat file and I don't understand why. 
In fact, I am being able to import the data but only the first and last column are recognized as a proper vector set. 
Could you please tell me why I am not being able to read SR and LC columns??? Please see the screenshot attached: 

  

As you can see, columns FC and DM are well read by R however the
 other two are not. I've also tried to import it as a csv sheet but the 
result was the same. 

Any help would be appreciated! 

Many thanks, 

Stoyan



More information about the R-help mailing list