Try this (I think your result in [2,2] is incorrect):
> dat <- read.table(tc <- textConnection(
+ '0,1 1,3 40,10 0,0
+ 20,5 4,2 10,40 10,0
+ 0,11 1,2 120,10 0,0'), as.is = TRUE)
> closeAllConnections()
> # split the data and create new matrix
> newDat <- lapply(dat, function(.col){
+ # split b
Hi,
Thanks again for your help with this. I would like to use a variation of
this function in a similar dataset (numeric) with elements separated by a
comma e.g.
dat <- read.table(tc <- textConnection(
'0,1 1,3 40,10 0,0
20,5 4,2 10,40 10,0
0,11 1,2 120,10 0,0'), sep="")
to simply calculate th
Hi
Just used this function on my real data - several enormous files (80 rows
by 200 columns...) and it worked perfectly! Thanks again for your help, saved
me a lot of time!
A last quick query, I have several other similar problems to deal with in my
data - do you know a useful book or onl
Here's another method without using any external regular expression libraries:
dat <- read.table(tc <- textConnection(
'0,1 1,3 40,10 0,0
20,5 4,2 10,40 10,0
0,11 1,2 120,10 0,0'), sep="")
mat <- apply(dat, c(1,2), function(x){
temp <- as.numeric(unlist(strsplit(x, ',')))
min(temp
On Fri, Oct 8, 2010 at 10:18 AM, Gabor Grothendieck
wrote:
> On Fri, Oct 8, 2010 at 1:19 AM, burgundy wrote:
>>
>> Hello,
>>
>> I have a dataframe (tab separated file) which looks like the example below -
>> two values separated by a comma, and tab separation between each of these.
>>
>> [,1]
On Fri, Oct 8, 2010 at 1:19 AM, burgundy wrote:
>
> Hello,
>
> I have a dataframe (tab separated file) which looks like the example below -
> two values separated by a comma, and tab separation between each of these.
>
> [,1] [,2] [,3] [ ,4]
> [1,] 0,1 1,3 40,10 0,0
> [2,] 20,5 4,2 10
Hi,
It is not the most elegant thing ever, but this does what you want. I
am *fairly* certain it generalizes to different sized matrices, but
I'd double check. When you divide by 0, it returns NaN, but this is
pretty easy to fix if you really want 0s using is.nan(). My general
process was: spli
7 matches
Mail list logo