All the solutions presented work, but, gosh,
why not fix the source file in the first place?
One way: Open the text file in Excel or a clone thereof, and tell the
importer dialog box to use both tabs and commas as delimiters. Then
save the result, which will have your 'third column' nicely sp
Thanks a lot to everyone who replied. I used some of Stephan Kolassa's
suggestions (thanks, Stephan). Here's my final code which worked (with
comments to explain novices like me who come looking for the same answer)
x=read.table("file",sep="\t",colClasses="character")
prate<-x[,2]
lrate<-x[,3] #th
On Dec 8, 2009, at 4:12 PM, Gaurav Moghe wrote:
> Hi David,
>
> 1) My code is as follows:
> x=read.table("file",sep="\t")
> prate<-x[,2]
> lrates<-(x[,3])
> When I do:
> print (typeof(lrates)): I get "integer"
You've already received several solutions from people more R-savvy
than I, so I wil
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Gaurav Moghe
> Sent: Tuesday, December 08, 2009 12:56 PM
> To: r-help@r-project.org
> Subject: [R] Split comma separated list
>
> Hi all,
>
>
Hi David,
1) My code is as follows:
x=read.table("file",sep="\t")
prate<-x[,2]
lrates<-(x[,3])
When I do:
print (typeof(lrates)): I get "integer"
When I do:
for (line1 in lrates) {
lsp<-unlist(strsplit(line1,"\\,"))
}
I get some in
Hi Gaurav,
1) tell R when reading the data to consider the third column as
"character" via the colClasses argument to read.table()
2) foo <- as.numeric(strplit(dataset$List_of_values,","))
3) unlist(foo) or some such
HTH,
Stephan
Gaurav Moghe schrieb:
Hi all,
I'm a beginner user of R. I
Gaurav -
Here's one way:
x = textConnection('ID1 0.342 0.01,1.2,0,0.323,0.67
+ ID2 0.010 0.987,0.056,1.3,1.5,0.4
+ ID3 0.146 0.1173,0.1494,0.211,0.1257
+
+ ')
y = read.table(x,stringsAsFactors=FALSE)
res = apply(y,1,function(x)
Two questions:
What is your code?
What do you get with:
> options()$dec
decimal_point
"."
--
David
On Dec 8, 2009, at 3:55 PM, Gaurav Moghe wrote:
Hi all,
I'm a beginner user of R. I am stuck at what I thought was a very
obvious
problem, but surprisingly, I havent found any
Hi all,
I'm a beginner user of R. I am stuck at what I thought was a very obvious
problem, but surprisingly, I havent found any solution on the forum or
online till now.
My problem is simple. I have a file which has entries like the following:
#ID Value1List_of_values
ID1
9 matches
Mail list logo