Re: [R] Parliament Seats Graph

2014-09-12 Thread Stefan Petersson
Yes. That's correct. The main problem is to solve a matrix where the colSums and rowSums are known. Credits to dwinsem...@comcast.net for pointing out the function r2dtable to me. Just feed it with the known margins and the number of matrices You want. And Bob is Your uncle! Look at the thread

[R] Margins to fill matrix

2014-09-11 Thread Stefan Petersson
Hi, I have two vector of margins. Now I want to create fill matrix that reflects the margins. seats - c(17,24,28,30,34,36,40,44,46,50) mandates - c(107,23,24,19,112,19,25,20) Both vectors adds up to 349. So I want a 10x8 matrix with row sums corresponding to seats and column sums

Re: [R] Margins to fill matrix

2014-09-11 Thread Stefan Petersson
at 10x8 matrix (i.e. 80 values). If you can clarify better we may be better able to help you. Charles On Thu, Sep 11, 2014 at 3:47 AM, Stefan Petersson ste...@inizio.se wrote: Hi, I have two vector of margins. Now I want to create fill matrix that reflects the margins. seats - c

Re: [R] Margins to fill matrix

2014-09-11 Thread Stefan Petersson
Carlson Department of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Stefan Petersson Sent: Thursday, September 11, 2014 7:13 AM To: Charles Determan Jr Cc: r

[R] Parliament Seats Graph

2014-09-08 Thread Stefan Petersson
Hi, Is there any package (or homegrown function) that can produce Parliament Seats Graph? I'm referring to the nice looking concentric half circles of colored seats as seen on Wikipedia (for example). I can pretty easily plot the points and color them. But I can't group the colored points in

[R] Real frequencies in a 'set' problem

2013-11-13 Thread Stefan Petersson
I have three media channels where I can push public health information (tv, radio and newspaper). Any given citizen can be touched by the information from one, two or three channels (let's ignore for the moment that citizens might miss the information all together). Hence these sets:

[R] R on Server without installation

2013-10-15 Thread Stefan Petersson
Hi, I use a regular web hosting service to build a web site under windows .NET. Now I need statistical functionality on the site, and I would really like to use R for that. However, I'm not allowed to install anything (e.g. R) on the host. Are there any implementations/workarounds of R that

[R] Repeating sequence elements

2013-05-17 Thread Stefan Petersson
I want to create a sequence, repeating each element according to a vector. I have this: v - c(4, 4, 4, 3, 3, 2) And want to create this: 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 5 5 5 6 6 TIA // s R version 3.0.0 (2013-04-03) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8

[R] Correct use of the cluster::daisy function

2013-01-08 Thread Stefan Petersson
Hi, I have two groups, and I want to find the dissimiarity between the members of the two groups. Since I have mixed level variables on the members, I opt for the daisy function in the cluster package. Let's pretend that the following represent my groups: x -

[R] clogit, modeling change...

2012-05-25 Thread Stefan Petersson
Hi, I've set up a discrete choice experiment on magazine preference following the guidelines from Azaiki. H Nishimura K. Design and Analysis of Choice Experiments Using R. A Brief Introuction from Agricultural Informatin Research 17(2), 2008. 86-94. I'm working with the clogit() function from

[R] Password protected R Repository

2011-09-28 Thread stefan . petersson
Hi, I've set up a very simple R repository. Just a single source library. Everything works fine. I can install the package on my client using: install.packages(repos='http://www.myServer.se/myRepo/', pkgs='myLib', dep=TRUE) However, I want to protect the repo, so I use a .htaccess, placed

Re: [R] Password protected R Repository

2011-09-28 Thread Stefan Petersson
stefan.petersson at inizio.se writes: Hi, I've set up a very simple R repository. Just a single source library. Everything works fine. I can install the package on my client using: install.packages(repos='http://www.myServer.se/myRepo/', pkgs='myLib', dep=TRUE) However, I want

Re: [R] Password protected R Repository

2011-09-28 Thread Stefan Petersson
. It then calls download.file to get the packages. So please read the help for download.file (as the help pages say), and try the solutions described there. On Wed, 28 Sep 2011, Stefan Petersson wrote: The helpfiles for 'download.file' was not that helpful. But maybe it's just me

Re: [R] Password protected R Repository

2011-09-28 Thread Stefan Petersson
The helpfiles for 'download.file' was not that helpful. But maybe it's just me not being able to read them correctly. Yes, looks like this is the case. I tried to call install.packages with the 'method=wget', and hoped for a username and password dialog. But no luck. The help

[R] Is function compiled code or not?

2011-04-08 Thread Stefan Petersson
Hi, Sorry for my ignorance, but how can I see if a function is 'compiled code' or plain R? E.g. the daisy function from the cluster package. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

[R] Two matrix loop

2011-03-24 Thread Stefan Petersson
Hi, I'm trying to create a distance matrix. And it works out somewhat ok. However, I suspect that there are some efficiency issues with my efforts. Plz have a look at this: donor - matrix(c(3,1,2,3,3,1,4,3,5,1,3,2), ncol=4) receiver -

[R] Markov Model problem

2010-09-17 Thread Stefan Petersson
First, I don't have the correct lingo for this topic, so I can't really find a solution for my problem. And maybe I formulate it incorrectly, so bear with me. How would I calculate a 'constant transition matrix' if I know a given value at a given time? Let's say I know that my value is 54,0

[R] Backslash in paste() function

2010-06-16 Thread Stefan Petersson
Hi, I'm trying to build a vector of latex commands. However, I need the command strings to begin with a backslash \. I have: test - c('foo','bar') and I need to rebuild the array, encapsulating the text items with latex stuff, like this: paste(\parbox[b]{3cm}{, test, }, fill=TRUE)

Re: [R] Backslash in paste() function

2010-06-16 Thread Stefan Petersson
Just double all the backslashes and you are fine. In order to see the outcome, use cat() (not print). Uwe Ligges On 16.06.2010 09:49, Stefan Petersson wrote: Hi, I'm trying to build a vector of latex commands. However, I need the command strings to begin with a backslash \. I

[R] Merging dataframe with list

2010-05-25 Thread Stefan Petersson
I often read SPSS system files (*.sav) into R using the 'read.spss' function from the 'foreign' library. To retain all the meta data, i.e. 'variable labels', I call the function like this: test.sav - read.spss('http://www.cdc.gov/healthyYouth/shpps/2006/spss/envs2006.sav',

[R] Dynamically build variable names

2010-05-17 Thread Stefan Petersson
I'm trying to dynamically build variable names to use on a list. Let's say I have a list like this one: l - list(V1_1=c(1,2,3), V1_2=c('One','Two','Three')) And I succesfully build my variable name like this: paste('l$', 'V1_1', sep='') Why can't I just run a mean call with the pasted

Re: [R] Dynamically build variable names

2010-05-17 Thread Stefan Petersson
I'm trying to dynamically build variable names to use on a list. Let's say I have a list like this one: l - list(V1_1=c(1,2,3), V1_2=c('One','Two','Three')) And I succesfully build my variable name like this: paste('l$', 'V1_1', sep='') Why can't I just run a mean call with the

[R] RMySQL, Sweave and the annoying TRUE echo

2010-01-29 Thread Stefan Petersson
Hi, A small (but annoying) problem with RMySQL library. When a connection is closed, it echoes 'TRUE' to the console. Like this: R mysqlCloseConnection(con) [1] TRUE The real problem comes when I use RMySQL with Sweave, since the TRUE echo gets into my final Sweave document. Even when I

[R] [SOLVED] RMySQL, Sweave and the annoying TRUE echo

2010-01-29 Thread Stefan Petersson
S: Works! Thanx... 2010-01-29 Henrique Dallazuanna wrote: Try this: invisible(mysqlCloseConnection(con)) On Fri, Jan 29, 2010 at 9:10 AM, Stefan Petersson stefan.peters...@inizio.se wrote: Hi, A small (but annoying) problem with RMySQL library. When a connection is closed, it echoes

[R] Formatting cgroup and factor level labels in Hmisc latex function

2010-01-26 Thread Stefan Petersson
I'm trying to typeset at simple crosstable with the Hmisc latex function. And I have two problems. 1. How do I make all columns the same width? The Latex function seems very unwilling to break the 'cgroup' labels and the factor level labels. Please have look at this screenshot that shows my

[R] Counting session days

2009-02-09 Thread stefan . petersson
hi, I have some session data in a dataframe, where each session is recorded with a start and a stop date. Like this: session_start session_stop === 2009-01-03 2009-01-04 2009-01-01 2009-01-05 2009-01-02 2009-01-09 A session is at least one day long. Now I want

[R] Combining all possible values of variables into a new...

2008-10-20 Thread stefan . petersson
I'm trying to create a new column in my data.frame where subjects are categorized depending on values on four other columns. In any other case I would just nest a few ifelse statements, however, in this case i have 4*6*2*3=144 combinations and i get weird 'context overflow' errors. So I wonder

[R] Error results from MS Access via RODBC

2008-09-24 Thread stefan . petersson
I have an MS Access database with one table and one column holding rep(1:10) I use: library(RODBC) channel - odbcConnect(test) sqlQuery(channel, paste(SELECT col FROM tblTest), believeNRows=FALSE) and get: 49 50 51 52 53 54 55 56 57 12337 What? The above should, of course, read: 1

[R] lpSolve replacement to solve transportation problem

2008-06-17 Thread stefan . petersson
r-help, I'm currently using 'lp.transport' from 'lpSolve' to solve a transportation problem. However, I've experienced some performence issues, and have been told that other solvers may perform better. I've looked briefly at 'Rsymphony' and 'rglpk', but I can't seem to figure out how/if they

[R] Matrix transformation problem

2008-06-11 Thread stefan . petersson
ng, I have a matrix (x) with binary content. Each row of the matrix holds exactly one 1, and the rest of the row is zeros. The thing is that I need to 'collapse' the matrix to one column where each row holds the original column index of the 1's (y). Sometimes, the matrix is quite large, so I