Actually I have one more question that's somewhat related-- I'm starting out
by importing a .txt file that isn't divided into vectors and is at times
inconsistent with regards to spacing, indents, etc., so I can't rely on
those.  It looks something like this:


"Drink=Coffee:Location=Office:Time=Morning:Market=Flat 

Drink=Water:Location=Office:Time=Afternoon:Market=Up 

Drink=Water:Location=Gym:Time=Evening:Market=Closed 
Drink=Wine:Location=Restaurant:Time=LateEvening:Market=Closed 
           Drink=Coffee:Location=Office:Time=Morning:Market=Flat 
Drink=Water:Location=Office:Time=Afternoon:Market=Up 

    Drink=Water:Location=Gym:Time=Evening:Market=Closed 
Drink=Wine:Location=Restaurant:Time=LateEvening:Market=Closed
Drink=Coffee:Location=Office:Time=Morning:Market=Flat 

Drink=Water:Location=Office:Time=Afternoon:Market=Up 

Drink=Water:Location=Gym:Time=Evening:Market=Closed 

Drink=Wine:Location=Restaurant:Time=LateEvening:Market=Closed"



How can I take a single string like this and divide it into twelve vectors,
like this:

FixedData
[1] "Drink=Coffee:Location=Office:Time=Morning:Market=Flat"        
[2] "Drink=Water:Location=Office:Time=Afternoon:Market=Up"         
[3] "Drink=Water:Location=Gym:Time=Evening:Market=Closed"          
[4] "Drink=Wine:Location=Restaurant:Time=LateEvening:Market=Closed"
[5] "Drink=Coffee:Location=Office:Time=Morning:Market=Flat"        
[6] "Drink=Water:Location=Office:Time=Afternoon:Market=Up"         
[7] "Drink=Water:Location=Gym:Time=Evening:Market=Closed"          
[8] "Drink=Wine:Location=Restaurant:Time=LateEvening:Market=Closed"
[9] "Drink=Coffee:Location=Office:Time=Morning:Market=Flat"        
[10] "Drink=Water:Location=Office:Time=Afternoon:Market=Up"         
[11] "Drink=Water:Location=Gym:Time=Evening:Market=Closed"          
[12] "Drink=Wine:Location=Restaurant:Time=LateEvening:Market=Closed"

Thanks again for all of the help!

--Andrew

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Search-and-extract-string-function-tp2290268p2290375.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.

Reply via email to