Skip to content
Prev 21347 / 29559 Next

Local_coord

On Sun, 20 Jul 2014, Lo?c Dutrieux wrote:

            
This may work, but is no help at all in understanding R - dplyr is very 
new, and the %.% or %>% syntax is even newer, and very confusing if the 
assumptions made in chaining the steps together are wrong. If you do 
things step-by-step, you can debug them:

coord <- read.table('Coord_ha_R.txt', header = TRUE, fill = TRUE)
str(coord)
% str() describes structure, so showing factors as such;
% head() doesn't do this - see dplyr documentation
ref_sub_parc_coord <- read.table("ref_sub_parc_coord.txt",
  header = TRUE)
str(ref_sub_parc_coord)
# create index
# ref_sub_parc_coord$Sub_parc <- seq(1,10)
# how does mutate() do this properly?
ref_sub_parc_coord$Sub_parc <- 1:nrow(ref_sub_parc_coord)
# merge two data frames
mm <- merge(ref_sub_parc_coord, coord, by = "Sub_parc")
str(mm)
mm$X_global = mm$X_local + mm$X
mm$Y_global = mm$Y_local + mm$Y
str(mm)

By the way, using dplyr:

all.equal(plots, mm)

Please always try to use standard R functions if possible; things like 
dlpyr may be helpful sometimes, but for working scientists simplicity and 
the ability to debug each step are really much more practical.

Roger