Hi:

Here's one way, but there may be better options:

de <- read.table(textConnection("
+
Subject,Sessionblock,LotteryImg,SubjectResp,Pictime,Bidtime,Voltage,ForcedAns
+ 10816,Session1,75_C2.jpg,No,7095,9548,Mid,Yes
+ 10816,Session1,25_C1.jpg,No,16629,18130,Low,Yes
+ 10816,Session1,5_C1.jpg,No,23217,24276,Low,Yes
+ 10816,Session1,75_C1.jpg,NULL,36359,-66179,Low,Yes
+ 10816,Session1,25_C2.jpg,NULL,49468,-66179,Mid,Yes
+ 10816,Session1,75_C3.jpg,Yes,60602,62119,High,Yes"), header = TRUE,
as.is= TRUE,
+   sep = ',')
> de
  Subject Sessionblock LotteryImg SubjectResp Pictime Bidtime Voltage
ForcedAns
1   10816     Session1  75_C2.jpg          No    7095    9548     Mid
Yes
2   10816     Session1  25_C1.jpg          No   16629   18130     Low
Yes
3   10816     Session1   5_C1.jpg          No   23217   24276     Low
Yes
4   10816     Session1  75_C1.jpg        NULL   36359  -66179     Low
Yes
5   10816     Session1  25_C2.jpg        NULL   49468  -66179     Mid
Yes
6   10816     Session1  75_C3.jpg         Yes   60602   62119    High
Yes
> str(de)
'data.frame':   6 obs. of  8 variables:
 $ Subject     : int  10816 10816 10816 10816 10816 10816
 $ Sessionblock: chr  "Session1" "Session1" "Session1" "Session1" ...
 $ LotteryImg  : chr  "75_C2.jpg" "25_C1.jpg" "5_C1.jpg" "75_C1.jpg" ...
 $ SubjectResp : chr  "No" "No" "No" "NULL" ...
 $ Pictime     : int  7095 16629 23217 36359 49468 60602
 $ Bidtime     : int  9548 18130 24276 -66179 -66179 62119
 $ Voltage     : chr  "Mid" "Low" "Low" "Low" ...
 $ ForcedAns   : chr  "Yes" "Yes" "Yes" "Yes" ...

In the read.table() call, replace all the textConnection("...blah blah...")
with the file name; everything starting with , header =TRUE, ...
should be kept in the call.
The as.is option reads all the character variables in as character rather
than the default conversion to factor. The colClasses option of read.table()
should give you more options.

HTH,
Dennis


On Mon, Aug 23, 2010 at 6:00 PM, Allie818 <alice.ly@gmail.com> wrote:

>
> I have a txt file with column data separated by commas.
>
>
> Subject,Sessionblock,LotteryImg,SubjectResp,Pictime,Bidtime,Voltage,ForcedAns
> 10816,Session1,75_C2.jpg,No,7095,9548,Mid,Yes
> 10816,Session1,25_C1.jpg,No,16629,18130,Low,Yes
> 10816,Session1,5_C1.jpg,No,23217,24276,Low,Yes
> 10816,Session1,75_C1.jpg,NULL,36359,-66179,Low,Yes
> 10816,Session1,25_C2.jpg,NULL,49468,-66179,Mid,Yes
> 10816,Session1,75_C3.jpg,Yes,60602,62119,High,Yes
>
> I have tried to read the data with this command
>
> data<-read.table("/mrdata/embodied_val/data/Conditioning_TIM4_082310.txt",sep
> = ",",header=T)
>
> but I get this error
> Error in make.names(col.names, unique = TRUE) :
>  invalid multibyte string at '<ff><fe>C'
>
> What am I doing wrong?
>
> Thanks,
> Alice
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Read-data-in-R-tp2336018p2336018.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.
>

	[[alternative HTML version deleted]]

