[R] Difficulty importing data from PARI/GP

arun smartpink111 at yahoo.com
Fri Dec 21 20:57:03 CET 2012


HI,

May be this helps:
Lines1<-"15,30,45;20,45,39;60,49,32;48,59,63"
res1<-read.table(text=unlist(strsplit(Lines1,split=";")),sep=",")
str(res1)
#'data.frame':    4 obs. of  3 variables:
# $ V1: int  15 20 60 48
# $ V2: int  30 45 49 59
# $ V3: int  45 39 32 63

#or
res2<-read.table(text=gsub(";","\n",Lines1),sep=",",stringsAsFactors=FALSE)
 res2
#  V1 V2 V3
#1 15 30 45
#2 20 45 39
#3 60 49 32
#4 48 59 63
identical(res1,res2)
#[1] TRUE
A.K.



----- Original Message -----
From: murfs <jm9461 at my.bristol.ac.uk>
To: r-help at r-project.org
Cc: 
Sent: Friday, December 21, 2012 12:39 PM
Subject: [R] Difficulty importing data from PARI/GP

I'm trying to import a matrix created in PARI/GP into R but am having
problems.
The data in the text file has entries separated by commas but the rows
themselves are separated by semicolons rathen than being on a new line. Is
there a way to get R to recognise that ";" means start a new row ?  



--
View this message in context: http://r.789695.n4.nabble.com/Difficulty-importing-data-from-PARI-GP-tp4653736.html
Sent from the R help mailing list archive at Nabble.com.

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





More information about the R-help mailing list