Protected: 从天而降的鸟屎

This post is password protected. To view it please enter your password below:


在word里使用latex

老早就接触到latex,但一直没用,曾经在linux下安装中文包和字体,环境搭建好了之后,就再也没用。

叶公好龙啊。。。

最近因为写个R的文档,得用latex,终于开始用了。还是很不错的。写公式实在是太方便了。

不过写写英文文档就算了,不会再去搞中文了。中文的还是老老实实用word吧。国内的软件环境基本上完全被微软QJ了。

在word里面写公式,实在是很麻烦。要编辑出美观的公式很费时间。所以就在想,要是能在word里用latex插入公式就好了。

google一下,找到了LaTeX in Word这个宏。通过“工具”->“模版和加载项”进行安装。

然后在使用Word的时候,按一下快捷键Alt-L就会弹出来一个latex编辑框。在里面敲入latex的代码。点convert,就会转化latex的代码并插入到word文档中。用来写公式,补word之短,相当方便。

latex-in-word

最近发现wikipedia里的公式,虽然是图片格式,但是选中,Ctrl-C,然后到文本编辑器里,Ctrl-V会贴进去相应的latex代码。。

Assignment token of R

when I recalled the *switch* function, it always gave the first element, no matter what the parameter is.

r-29-dev

when *organism* changed to “yeast”, and called *switch* function, *species* supposed to be changed to “Sc”, but it remains it’s original value.

After I read the manual, I change “< -" to "=", and it works as I expected.

r-29-switch

In R, the assignment token is “< -" but not "=". "=" is equivalent to "<-" when assign a value. At this time, it's not to assign a value but to name an alternative.

It's curious but this is the syntax of R.

The authors of R once said: syntax is superficial.

I know syntax is not the essential of a language, but it's the way how we express our ideas. At this point, it's the most important thing. This maybe the reason why they chose S as the syntax of R, since S is designed for statistical computing.

I really hate the syntax sometimes.

Read the rest of this entry »

Perl的unique函数

好久没写代码,有些生疏,连keyword都会打错,囧。。。

今天才发现perl里没有unique函数,只能自己写了,最容易的做法当然是用哈希,因为哈希的键是唯一的。使用map函数,一条语句就可以实现了。

1
2
3
4
5
6
7
8
9
10
11
12
 #!/usr/bin/perl -w
 use strict;
 
 sub unique (&@){
     my $a_ref = shift;
     my %hash = map {$_ => 1}  @$a_ref;
     my @unique_array = sort (keys %hash);
     return @unique_array;
 }
 
 my @array = (1..10, 5..13);
 print join("\n", unique(\@array)), "\n";

Protected: 海角七号

This post is password protected. To view it please enter your password below:


Pages: Prev 1 2 3 4 5 6 7 8 ...24 25 26 Next