Sorry.. my bad.. I should have done
z = lapply(z, as.numeric)
That works.
Shank

From: Khanvilkar, Shashank
Sent: Wednesday, February 09, 2011 1:33 PM
Cc: r-help@r-project.org
Subject: RE: [R] Question on sapply

Thanks,
Nopes.. Does not seem to work.
> lapply(z, as.numeric)
[[1]]
[1] 1 1

[[2]]
[1] 2 2

[[3]]
[1] 3 3

[[4]]
[1] 4 4

> typeof(z[[1]][1])
[1] "character"
Shank

From: Henrique Dallazuanna [mailto:wwwhsd@gmail.com]
Sent: Wednesday, February 09, 2011 12:34 PM
To: Khanvilkar, Shashank
Cc: r-help@r-project.org
Subject: Re: [R] Question on sapply

Try this:

lapply(z, as.numeric)
On Wed, Feb 9, 2011 at 5:16 PM, Khanvilkar, Shashank <skhanvil@qualcomm.com<mailto:skhanvil@qualcomm.com>> wrote:
Hello All,
Thanks in advance for all help
I have the following vector of strings that I want to split..

> y = c("1/1","2/2", "3/3", "4/4")
> y
[1] "1/1" "2/2" "3/3" "4/4"
> z = strsplit(y,"/")
> z
[[1]]
[1] "1" "1"

[[2]]
[1] "2" "2"

[[3]]
[1] "3" "3"

[[4]]
[1] "4" "4"

Now how do I convert all elements of z to an interger.. (currently t, it is of type character)
I believe sapply is the correct function, but don't know what the syntax is.

Thanks
Shank


       [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org<mailto: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.



--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]

