[R] choosing items from array: very stupid and simple question

2012-01-08 Thread Philipp Chapkovski
x<-1:11
y<-2:3

is there a way to do something like
x[x==y]
(which actually produce error)?
I am really got stuck

__
R-help@r-project.org mailing list
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.


[R] how to just download file on disk by the link

2011-12-05 Thread Philipp Chapkovski
Sorry for stupid question but is there any way to just download file (excel
file) from the url to the disk with a certain name?
Now it seems that I should open it (via read.xls) and then write it by
write.xls. But I am pretty sure it should be something much easier?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


[R] Problem with parsing HTML table

2011-12-05 Thread Philipp Chapkovski
Hello!
Can anybody help to convert this table (in fact there are two adjacent
tables) into dataset?
http://www.khantu-mansy.vybory.izbirkom.ru/region/region/khantu-mansy?action=show&root=86214&tvd=2862000216095&vrn=100100028713299®ion=86&global=true&sub_region=86&prver=0&pronetvd=null&vibid=2862000216095&type=233
with ReadHTMLTable it doesn't work at all :(

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


[R] convert table to a string in matrix

2011-12-04 Thread Philipp Chapkovski
Hello everybody! I need help in collecting the information about Russian
elections.

There is a table at the web-site
http://www.moscow_city.vybory.izbirkom.ru/region/region/moscow_city?action=show&root=774003008&tvd=477400389537&vrn=100100028713299®ion=77&global=true&sub_region=77&prver=0&pronetvd=null&vibid=477400389537&type=242
the problem is how to convert this table to a string in order to add it to
the table with 25 columns. ReadHTMLTable doesn't work because I need only
bold digits and it takes both normal and bold digits and stick them
together.
What can be done?
Thanks!
Philipp

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


[R] how to get url content with "?" (question mark) inside

2011-08-28 Thread Philipp Chapkovski
There is an url
"http://www.ozon.ru/context/detail/id/5254326/?type=6#buyalso";
If I try to get the data there (by "readLines" or whatever), R
downloads actually the content of this url
""http://www.ozon.ru/context/detail/id/5254326";
that is till the question mark.

What should I do to avoid the problem?
Thanks!
Philipp

__
R-help@r-project.org mailing list
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.


[R] how to convert careers to social network description

2011-06-14 Thread Philipp Chapkovski
There is a dataframe in R that looks that
Person --- Organization --- Year In --- Year Out
   P1X   20012005
   P2X   20022006

What is the most quick way to convert it to the table of the
connections between two people with a 'strength' equal the number of
years they worked together?
In this example the result should be something like:
Person 1 --- Person 2 --- Strength
 P1 P2  4

It seems to me that should be some quick and compact way to do this
conversion but I don't know how. Thank you for any hints!

Philipp

__
R-help@r-project.org mailing list
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.


Re: [R] how to combine two data frames via factors (or somehow else)

2011-05-30 Thread Philipp Chapkovski
Thank you very much for your help - everybody, and especially Joshua!

On Mon, May 30, 2011 at 1:21 AM, Joshua Wiley  wrote:
> Hi Philipp,
>
>
> ## Read in your data
> ## posting the output of dput() would have made our lives easier
> d1 <- read.table(textConnection("x y
> 1 a X
> 2 b X
> 3 c X
> 4 f Z
> 5 e Z
> 6 g Z"), header = TRUE, row.names = 1)
> d2 <- read.table(textConnection(" y1 y2
> 1  X W
> 2  Z W"), header = TRUE, row.names = 1)
> closeAllConnections()
>
> ## Solution using merge()
> dboth <- merge(d1, d2, by.x = "y", by.y = "y1")
>
> ## an alternate solution in this case
> d1.alt <- d1
> d1.alt$owner <- d2[d2$y1[d1$y], "y2"]
>
> ## Compare them
> dboth
> d1.alt
>
> Hope this helps,
>
> Josh
>
> On Sun, May 29, 2011 at 1:51 PM, Philipp Chapkovski
>  wrote:
>> Hello!
>> The question should be very naive, but I am a beginner and stuck with
>> this unfortunately.
>> There is a dataset of people's affiliation to companies that looks
>> like that (a data frame actually)
>>  x y
>> 1 a X
>> 2 b X
>> 3 c X
>> 4 f Z
>> 5 e Z
>> 6 g Z
>> where x is a name of a person and y is a company name. That is, a,b,c
>> work in a company X. f,e,g work in a company Z.
>>
>> and there is another dataset with the affiliation of companies. Like
>> that (much much longer in reality):
>>  y1 y2
>> 1  X W
>> 2  Z W
>> that means that both X and Z belongs to the same company W.
>> What is the most compact way (without loops etc) to 'attach' the 'head
>> company' from the second dataset to the first dataset so I can have
>> something like:
>>
>>  x  y owner
>> 1 a X W
>> ...
>> 4 f  Z W
>>
>> I know it should be done somehow with factors, but I don't know how.
>> Thank you in advance!
>>
>> __
>> R-help@r-project.org mailing list
>> 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.
>>
>
>
>
> --
> Joshua Wiley
> Ph.D. Student, Health Psychology
> University of California, Los Angeles
> http://www.joshuawiley.com/
>

__
R-help@r-project.org mailing list
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.


[R] how to combine two data frames via factors (or somehow else)

2011-05-29 Thread Philipp Chapkovski
Hello!
The question should be very naive, but I am a beginner and stuck with
this unfortunately.
There is a dataset of people's affiliation to companies that looks
like that (a data frame actually)
  x y
1 a X
2 b X
3 c X
4 f Z
5 e Z
6 g Z
where x is a name of a person and y is a company name. That is, a,b,c
work in a company X. f,e,g work in a company Z.

and there is another dataset with the affiliation of companies. Like
that (much much longer in reality):
  y1 y2
1  X W
2  Z W
that means that both X and Z belongs to the same company W.
What is the most compact way (without loops etc) to 'attach' the 'head
company' from the second dataset to the first dataset so I can have
something like:

  x  y owner
1 a X W
...
4 f  Z W

I know it should be done somehow with factors, but I don't know how.
Thank you in advance!

__
R-help@r-project.org mailing list
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.