Re: [R] Newbie in R: Reading .txt files and storing the 'numbers' in a vector

2009-07-31 Thread 1Rnwb

I am also a newbie, but here are the few thing i do
eo=read.table(file=path where you have saved your text
file/xxx.txt,header=T, )   
#this will only read excelfiles saved
as *.csv file
attach(eo)  
#attach the data
names(eo)

go to this website http://www.statmethods.net/stats
here is how to store numbers as vectors
a-c(1,2,3,4,5,6,7)
here is how i means as vector
d-aggregate(LMMP8,list(PlateID,Self_T1D),mean, na.rm=T)

I would suggest u to search for website for R tutorials
here are some good ones
go to this website http://www.statmethods.net/stats
http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_ttest.html
this one has all the codes you can change them according to your data
http://www3.imperial.ac.uk/pls/portallive/docs/1/1171930.TXT
http://www.mayin.org/ajayshah/KB/R/index.html

also download the book by verjani it would be a great help to you.



Patrick Schorderet wrote:
 
 
 Hello everybody,
 
 I'm a newbie in R and just went through an introduction class recently.
 
 Here's my problem.
 I have 2 text files (.txt) with plain numbers ('doubles' for those who  
 know c++) ordered into 2 columns as below:
 
 coordinate1   value1
 coordinate2   value2
 coordinate3   value3
 ...   ...
 coordinateN   valueN
 
 I would like to write a small programme in which i would:
 1. take all values of file 1 and store them in a vector
 2. substract to those all values of file 2 (one by one) and store the  
 result in a new vector
 3. Create a sliding window of chosen size and calculate the  
 mathematical average and store these averages in a new vector
 4. Plot the different graphes with a bar plot
 
 So I wrote a c++ script that does the first parts and writes the  
 averages in a output.txt file (which I have up and running).  
 Unfortunately, I seem to fail in reading these as numbers and putting  
 them into a vector (in the R environment). I can read the file , but  
 this is what I get:
 
   z=scan(file = /Users/NCCRGENETICS/Desktop/testRnumbers.txt, what  
 = double)
 Read 19 items
   z
   [1] {\\rtf1\\ansi\\ansicpg1252\\cocoartf949\\cocoasubrtf430
   [2] {\\fonttbl\\f0\\fswiss\\fcharset0
   [3] Helvetica;}
   [4] {\\colortbl;\\red255\\green255\\blue255;}
   [5] \\paperw11900\\paperh16840\\margl1440\\margr1440\\vieww9000\ 
 \viewh8400\\viewkind0
   [6] \\pard\\tx566\\tx1133\\tx1700\\tx2267\\tx2834\\tx3401\\tx3968\ 
 \tx4535\\tx5102\\tx5669\\tx6236\\tx6803\\ql\\qnatural\\pardirnatural
   [7] \\f0\\fs24
   [8] \\cf0
   [9] 13\\  // This is where my file should start 
  
 reading the numbers I see in the window when I open it with textedit
 [10] 27\\
 [11] 39\\
 [12] 48\\
 [13] 34\\
 [14] 17\\
 [15] 23\\
 [16] 45\\
 [17] 23\\
 [18] 4\\
 [19] }
  
 
 Thanks so much to any of you who could provoid a little help... I'm  
 getting nuts.
 Patrick
 
 __
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Newbie-in-R%3A-Reading-.txt-files-and-storing-the-%27numbers%27-in-a-vector-tp24714734p24757501.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] Newbie in R: Reading .txt files and storing the 'numbers' in a vector

2009-07-29 Thread Patrick Connolly
On Wed, 29-Jul-2009 at 10:29AM +0200, Patrick Schorderet wrote:


 Hello everybody,

 I'm a newbie in R and just went through an introduction class recently.

Did you get the distinction between a vector and a dataframe? 



 Here's my problem.
 I have 2 text files (.txt) with plain numbers ('doubles' for those who  
 know c++) ordered into 2 columns as below:

 coordinate1   value1
 coordinate2   value2
 coordinate3   value3
 ...   ...
 coordinateN   valueN

 I would like to write a small programme in which i would:
 1. take all values of file 1 and store them in a vector

I'm fairly certain you need a dataframe, hence the recommendation to
look at read.table.



 2. substract to those all values of file 2 (one by one) and store the  
 result in a new vector
 3. Create a sliding window of chosen size and calculate the mathematical 
 average and store these averages in a new vector
 4. Plot the different graphes with a bar plot

Those will follow simply once you have the first part working.

HTH

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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.