Dear all

I want to put arrows from other data to ggplot and get strange behaviour.

The code:

p<-ggplot(ram.ag, aes(Raman, XRD, colour=mereni))
p+geom_point(size=5)+geom_segment(data=dat, aes(x=Ramanpuv, 
y=XRDpuv,xend=Ramannov, yend=XRDnov),
arrow = arrow(length = unit(1,"cm")))

results to following error

Error in eval(expr, envir, enclos) : object 'mereni' not found

The working code (with bad legend)

p<-ggplot(ram.ag, aes(Raman, XRD, colour=mereni))
p+geom_point(size=5)+geom_segment(data=dat, aes(x=Ramanpuv, 
y=XRDpuv,xend=Ramannov,
yend=XRDnov, colour="black"), arrow = arrow(length = unit(1,"cm")))

I know how to improve legend manually but I wonder why the first code results 
in error, why in the second code black colour is ignored but results in no 
error.

Data:

ram.ag <- structure(list(vzorek = c("1.5 1:00", "1.5 11:00", "1.6 19:00",
"12.5 21:00", "16.5 17:00", "17.4 19:00", "17.5 9:00", "18.5 15:00",
"18.5 17:00", "27.5 7:00", "30.4 13:00", "4.6 17:00", "8.4 5:00",
"1.5 1:00", "1.5 11:00", "1.6 19:00", "12.5 21:00", "16.5 17:00",
"17.4 19:00", "17.5 9:00", "18.5 15:00", "18.5 17:00", "27.5 7:00",
"30.4 13:00", "4.6 17:00", "8.4 5:00"), mereni = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("nove", "puvodni"
), class = "factor"), Raman = c(98.2333333333333, 98.5, 99.9,
97.5333333333333, 92.375, 97.9666666666667, 98.225, 95.3, 90.5,
99.6, 97.45, 92.1, 98.45, 95.1, 99.1, 99.9, 97.9, 95.7, 97.6,
94.8, 97, 93.1, 99.3, 91.5, 88.9, 99.2), XRD = c(99.4, 99.4666666666667,
99.88, 99.6666666666667, 96.025, 99.5666666666667, 99.5, 98.75,
96.3333333333333, 99.725, 98.75, 97.425, 99.55, 98.9, 98.9, 99.3,
98.9, 94.7, 98.9, 98.9, 96.2, 96.2, 98.9, 97.4, 94.7, 97.4)), .Names = 
c("vzorek",
"mereni", "Raman", "XRD"), row.names = c(NA, -26L), class = "data.frame")

dat <- structure(list(Ramanpuv = c(95.1, 99.1, 99.9, 97.9, 95.7, 97.6,
94.8, 97, 93.1, 99.3, 91.5, 88.9, 99.2), XRDpuv = c(98.9, 98.9,
99.3, 98.9, 94.7, 98.9, 98.9, 96.2, 96.2, 98.9, 97.4, 94.7, 97.4
), Ramannov = c(98.2333333333333, 98.5, 99.9, 97.5333333333333,
92.375, 97.9666666666667, 98.225, 95.3, 90.5, 99.6, 97.45, 92.1,
98.45), XRDnov = c(99.4, 99.4666666666667, 99.88, 99.6666666666667,
96.025, 99.5666666666667, 99.5, 98.75, 96.3333333333333, 99.725,
98.75, 97.425, 99.55)), .Names = c("Ramanpuv", "XRDpuv", "Ramannov",
"XRDnov"), row.names = 14:26, class = "data.frame")

sessionInfo()
R Under development (unstable) (2016-03-15 r70334)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 10586)

locale:
[1] LC_COLLATE=Czech_Czech Republic.1250  LC_CTYPE=Czech_Czech Republic.1250
[3] LC_MONETARY=Czech_Czech Republic.1250 LC_NUMERIC=C
[5] LC_TIME=Czech_Czech Republic.1250

attached base packages:
[1] stats     datasets  utils     grDevices graphics  methods   base

other attached packages:
[1] devEMF_2.0      ggplot2_2.1.0   lattice_0.20-33 fun_0.1

loaded via a namespace (and not attached):
 [1] labeling_0.3     colorspace_1.2-6 scales_0.4.0     plyr_1.8.3
 [5] tools_3.3.0      gtable_0.2.0     Rcpp_0.12.4      nlme_3.1-126
 [9] grid_3.3.0       digest_0.6.9     munsell_0.4.3
>

Maybe it is version specific so I will try to check but I do not want to 
reinstall everything just now without a reason.

Best regards
Petr Pikal
Precheza a.s
724008364

"Kdo vždy myslí, že se učí,
bude vlasti chlouba.
Kdo si myslí, že dost umí,
začíná být trouba."
Karel Havlíček Borovský


________________________________
Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to