0

I will need to create a list (only $z) from data.frame. The list has to look like this:
$x ...
$y ...
$z
Cod Haddock Hake Saithe Whiting
-0.5, 50.75 0 1 0 0 0
-10.5, 48.75 0 0 16872 0 0
-10.5, 49.75 315 280 5221 35 23
...

I have a data.frame like this:
row.names x y z.small z.big z.middle
1 4253.41,7524.24 4253.41 7524.24 0.00000000 0.0000000000 1.0000000
2 4564.54,8442.45 4564.54 8442.45 0.00000000 0.0000000000 1.0000000
3 3858.31,8862.94 3858.31 8862.94 0.00000000 0.0000000000 1.0000000
...

Now, I need to transform this (second) data.frame to list into $z. But I am stock. Heres an example code for R:

row.names=c(("4253.41,7524.24"),("4564.54,8442.45"),("3858.31,8862.94"))
x=c(4253.41,4564.54,3858.31)
y=c(7524.24,8442.45,8862.94)
z.Small=c(0.000,0.000,0.000)
z.Big=c(0.000,0.000,0.000)
z.Mid=c(1.000,1.000,1.000)
(data=data.frame(row.names,x,y,z.Small,z.Big,z.Mid))

row.names            x       y          all z.Big z.Mid
1 4253.41,7524.24 4253.41 7524.24       0     0     1
2 4564.54,8442.45 4564.54 8442.45       0     0     1
3 3858.31,8862.94 3858.31 8862.94       0     0     1



Now I can create a list like this:
x=as.list(c(data$x))
y=as.list(c(data$y))
z= ????
xyz=list(x=(x), y=(y), z=(z))
sgt Fury
  • 170
  • 1
  • 7
  • If `$x` and `$y` come from a list (say `data`), you can `data$z <- your.data.frame`. – Roman Luštrik Dec 10 '14 at 12:34
  • no, no I need to transform bottom data.frame to list into a member of list $z. – sgt Fury Dec 10 '14 at 12:38
  • Then I'm afraid I don't fully understand what you're after. Can you produce a schematic (use ascii, no need for drawings) that demonstrates what you're after? – Roman Luštrik Dec 10 '14 at 12:41
  • data(landings) xyz <- make.xyz(landings$Lon,landings$Lat,landings$LiveWeight,landings$Species)
    if you look at xyz list at member $z. I try the ascii w8 a moment please.
    – sgt Fury Dec 10 '14 at 12:45
  • You can look at it here: http://postimg.org/image/iid05330v/ – sgt Fury Dec 10 '14 at 13:04
  • Perfect. Can you now make a reproducible example? [Here are a few tips on making one](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Roman Luštrik Dec 10 '14 at 13:06
  • @RomanLuštrik I have added some example. It is correct example? – sgt Fury Dec 11 '14 at 07:57

0 Answers0