-
-
Save memilanuk/4563592111b2a80d6f452fddc14aba74 to your computer and use it in GitHub Desktop.
require(lattice) | |
require(spatial) | |
groups <- read.csv(file="Desktop/damoncali.csv",head=TRUE,sep=",") | |
groups$x <- groups$CBTO | |
groups$y <- groups$Charge | |
groups$z <- groups$ES.MOA | |
x.Margin <- 0.00 | |
y.Margin <- 0.0 | |
groups.ls <- surf.ls(3, groups$x, groups$y, groups$z) | |
groups.surface <- trmat(groups.ls, min(groups$x) - x.Margin, max(groups$x) + x.Margin, min(groups$y) - y.Margin, max(groups$y) + y.Margin, 500) | |
str(groups.surface) | |
colfunc <- colorRampPalette(c("green", "yellow", "orange", "red")) | |
image(groups.surface, col = colfunc(12)) #heat.colors(20)) | |
contour(groups.surface, labcex = .75, add=T, nlevels = 20) | |
points(groups$x, groups$y) | |
title( | |
xlab="CBTO (in)", | |
ylab="Varget (gr)" | |
) |
Yeah... the file locations aren't an issue; it looks like this bug for the Debian Linux flavors of R may be what is biting me in the butt... running Linux Mint 18 on a Dell Chromebook 13, using RStudio.
I'm using R 3.3.3 for what it's worth.
Okay... that was a PITA. Tried downgrading the r-base
package, hoping the others would follow suite... no go. Ended up uninstalling all of R, and re-installing it. Then updating the stuff pulled in as a part of r-base
, which forced a recompile of the offending packages. Seems to be working now.
@damoncali question on the code... any particular reason you took columns from the CSV file i.e. groups$CTBO
and turned around and created new columns in the data frame i.e. groups$x
instead of just x <- groups$CTBO
?
I went thru and changed all the other references to groups$x
and groups$y
to just x
and y
, and the script / plot still seems to work just fine, and looks a bit cleaner as well.
require(lattice)
require(spatial)
groups <- read.csv(file="damoncali.csv",head=TRUE,sep=",")
x <- groups$CBTO
y <- groups$Charge
z <- groups$ES.MOA
x.Margin <- 0.00
y.Margin <- 0.0
groups.ls <- surf.ls(3, x, y, z)
groups.surface <- trmat(groups.ls, min(x) - x.Margin, max(x) + x.Margin, min(y) - y.Margin, max(y) + y.Margin, 501)
str(groups.surface)
colfunc <- colorRampPalette(c("green", "yellow", "orange", "red"))
image(groups.surface, col = colfunc(12)) #heat.colors(20))
contour(groups.surface, labcex = .75, add=T, nlevels = 20)
points(x, y)
title(
xlab="CBTO (in)",
ylab="Varget (gr)"
)
The code is a little sloppy. I wasn't sure what I was going to do with it and never really thought anyone else would ever see it, honestly. So yeah, there are some weird spots. I basically stoped working on it the second it worked. :)
This is how I run it (on my mac). If you run it again, it just overwrites the Rplots.pdf file (which is the one it generates). You need the script on and the csv file in the same directory and it should just work. Not sure what it's like on a non-mac.