Re: [R] function input as variable name (deparse/quote/paste) ??

2012-03-11 Thread Hans Ekbrand
the returned list. - run your function with sapply() and the returned list of sapply will be a list of lists. -- Hans Ekbrand (http://sociologi.cjb.net) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do rea

Re: [R] function input as variable name (deparse/quote/paste) ??

2012-03-10 Thread Hans Ekbrand
values in a list, or vector? What is gained by storing that info in the variable _name_ ? Your function could return a list with both the result and the input value. While you did say that this was part of something complex, I suspect your post might be a case of "

Re: [R] Issues in installing rgl in Mac OS 10.6.8

2012-03-10 Thread Hans Ekbrand
our system has the _runtime_ libraries for X11 (in /usr/X11), but you need _development_ libraries to comile rgl. I have no knowledge about Mac OS, but in my system, Debian GNU/Linux, the needed libraries to build rgl from source are: libgl1-mesa-dev li

Re: [R] hierarchical clustering of large dataset

2012-03-10 Thread Hans Ekbrand
, then test the distribution of species in clusters. -- Hans Ekbrand (http://sociologi.cjb.net) __ 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.

Re: [R] How do I force confint() for glm() to be quiet?

2012-03-09 Thread Hans Ekbrand
On 2012-03-09 15:30, David Winsemius wrote: On Mar 9, 2012, at 6:14 AM, Hans Ekbrand wrote: I need confint() for glm() to supress the messages I'm wondering if suppressMessages would be helpful? Which in turn suggests that you do not know how to use "??", so firt you sho

[R] How do I force confint() for glm() to be quiet?

2012-03-09 Thread Hans Ekbrand
I need confint() for glm() to supress the messages "Waiting for profiling to be done..." because they mess up the caching mechanism of pgfSweave (see https://github.com/cameronbracken/pgfSweave/issues/40). I have read the help page of confint(), but I do not know how to get the help page for th

Re: [R] speed up merge

2012-03-02 Thread Hans Ekbrand
w vectors out of that vector. If you elaborate on the problem, perhaps we could find a way to avoid the loops altogether? Mostly as a note to self, I wrote http://code.cjb.net/vectors-instead-of-loop.html, it might be understood by others too, but I'm not sure. -- Hans Ekbrand (http://soc

Re: [R] data analysis

2012-02-28 Thread Hans Ekbrand
#x27;s quite a general request. I think you should try to formulate a specific question. Have you read the posting-guide? http://www.R-project.org/posting-guide.html Also, I don't think the list accepts attached files. -- Hans Ekbrand (http://sociologi.cjb.net) _

Re: [R] count how many row i have in a txt file in a directory

2012-02-26 Thread Hans Ekbrand
s){ > n <- n + nrow(x) > break > } > n <- n + nrows > } > n > } But hey, programming R is fun, so why not? -- Hans Ekbrand __ R-help@r-projec

Re: [R] count how many row i have in a txt file in a directory

2012-02-26 Thread Hans Ekbrand
On Sun, Feb 26, 2012 at 05:06:42PM +0100, gianni lavaredo wrote: > thanks Hans. > > It's true your idea improve the speed in the analysis respect a row-by-row > loop. > > Sorry if I ask these questions to better understand and better performening > my code: > > 1) split command in GNU coreutils,

Re: [R] count how many row i have in a txt file in a directory

2012-02-26 Thread Hans Ekbrand
On Sun, Feb 26, 2012 at 03:03:58PM +0100, gianni lavaredo wrote: > Dear Researchers, > > I have a large TXT (X,Y,MyValue) file in a directory and I wish to import > row by row the txt in a loop to save only the data they are inside a buffer > (using inside.owin of spatstat) and delete the rest. Th

Re: [R] which is the fastest way to make data.frame out of a three-dimensional array?

2012-02-25 Thread Hans Ekbrand
em.time(my.df <- cbind(temp=c(foo), expand.grid(dim1=1:n[1], dim2=1:n[2], > dim3=1:n[3]))) user system elapsed 0.980 0.252 1.244 > -- Hans Ekbrand (http://sociologi.cjb.net) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/

[R] which is the fastest way to make data.frame out of a three-dimensional array?

2012-02-25 Thread Hans Ekbrand
8 0.54 0.285 -1.153 ... (In the real world problem I had, data was monthly measurements of temperature and x, y was coordinates). Does anyone care to share a faster and less ugly solution? TIA -- Hans Ekbrand __ R-help@r-project.org mailing list ht

Re: [R] Behaviour of 'source' with URLs and proxy

2011-10-05 Thread Hans Ekbrand
On Wed, Oct 05, 2011 at 12:44:12PM +0200, Renaud Gaujoux wrote: > Is source supposed to work through a proxy? This worked for me: > Sys.setenv(http_proxy="http://192.168.0.252:8118";) > source("http://pc5.socio.gu.se:84/enkel-kurva.r";, echo = T) > my.vectory = c(1,30,2,3,3,4) > my.vectorx = c(1,

Re: [R] Synchronizing R libraries on N machines?

2011-08-26 Thread Hans Ekbrand
On Thu, Aug 25, 2011 at 08:25:02AM -0500, Giovanni Petris wrote: > Hello! > > I am using R on two different machines (under Ubuntu and OS X, but this > is probably irrelevant) and I would like to keep the two installations > 'synchronized', in particular in terms of installed packages. For > examp

[R] [Solved] Re: lavaan: how to analyse residuals of a latent variable

2011-08-09 Thread Hans Ekbrand
my situation, is this documented somewhere? My understanding of latent variable analysis is indeed limited, but I did not understand that lavaan worked liked this when I read the documentation. Kind regards, Hans Ekbrand signature.asc Description: Digital signature

Re: [R] lavaan: how to analyse residuals of a latent variable

2011-08-09 Thread Hans Ekbrand
150.039 school.adapti 0.004 0.0020.005 school.grades-0.012 -0.010 -0.026 criminality 0.327 0.1910.505 Are the other estimates reasonable estimates of the part of va

[R] importing spss-files [ was: "Re: need your consult"]

2011-08-09 Thread Hans Ekbrand
/foreign/foreign.pdf Basically, it can be as simple as library(foreign) foo <- read.spss(file = "data_set.sav") now, your data is in object "foo", which can be inspected with the function str() str(foo) -- Hans Ekbrand signature.asc Description: Digital signature _

[R] lavaan: how to analyse residuals of a latent variable

2011-08-09 Thread Hans Ekbrand
my.fit, fit.measures = T, standardized = T) -- Hans Ekbrand Department of Sociology University of Gothenburg Sweden signature.asc Description: Digital signature __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLE

[R] confint.multinom() slow?

2011-05-12 Thread Hans Ekbrand
get CI:s for the odds ratios, and have tried confint() my.cis <- confint(my.fit) I started confint() a few hours ago, but now I'm getting suspicious, since it hasn't terminated yet. Perhaps I just lack the reasonable patience, but is such a long computational time for confint() to be

Re: [R] Cluster analysis, factor variables, large data set

2011-03-31 Thread Hans Ekbrand
On Thu, Mar 31, 2011 at 08:48:02PM +0200, Hans Ekbrand wrote: > On Thu, Mar 31, 2011 at 07:06:31PM +0100, Christian Hennig wrote: > > Dear Hans, > > > > clara doesn't require a distance matrix as input (and therefore > > doesn't require you to run daisy), it w

Re: [R] Cluster analysis, factor variables, large data set

2011-03-31 Thread Hans Ekbrand
On Thu, Mar 31, 2011 at 07:06:31PM +0100, Christian Hennig wrote: > Dear Hans, > > clara doesn't require a distance matrix as input (and therefore > doesn't require you to run daisy), it will work with the raw data > matrix using > Euclidean distances implicitly. > I can't tell you whether Euclide

[R] Cluster analysis, factor variables, large data set

2011-03-31 Thread Hans Ekbrand
his kind of data on large data set? regards, Hans Ekbrand __ 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, s

Re: [R] how to make list() return a list of *named* elements

2010-10-04 Thread Hans Ekbrand
On Mon, Oct 04, 2010 at 04:10:46PM +0200, Christophe Pallier wrote: > See llist from Hmisc package: > > library(Hmisc) > a=rnorm(10) > b=rnorm(5) > llist(a,b) Ah, that seems like what I want! My old, ugly and redunant code looked like this list(utdrag=utdrag, n.fires.at.sites.with.one

Re: [R] how to make list() return a list of *named* elements

2010-10-04 Thread Hans Ekbrand
On Mon, Oct 04, 2010 at 10:07:06AM -0400, Gabor Grothendieck wrote: > Some small tweaks. If you use simplify=FALSE then it will guarantee > that a list is returned: > >sapply(my.names, get, simplify = FALSE) > > for example, compare the outputs of: > >sapply(c("letters", "LETTERS"), ge

Re: [R] how to make list() return a list of *named* elements

2010-10-04 Thread Hans Ekbrand
eal cases with longer variable names and a lot of variables to return. Thanks Henrique! -- Hans Ekbrand (http://sociologi.cjb.net) Q. What is that strange attachment in this mail? A. My digital signature, see www.gnupg.org for info on how you could use it to ensure that this mail is from me and h

Re: [R] how to make list() return a list of *named* elements

2010-10-04 Thread Hans Ekbrand
gt; 1 22.48 > 2 12.29 > 3 10.9 15 > 4 8.51 > 5 9.2 14 Thanks for your suggestion. However, the reason I used list() was that the different vectors to return usually have different lengths. Admittedly, I should have used another example that explicated this. -- Ha

Re: [R] how to make list() return a list of *named* elements

2010-10-04 Thread Hans Ekbrand
On Mon, Oct 04, 2010 at 07:51:10PM +0800, Berwin A Turlach wrote: > R> my.return <- function (vector.of.variable.names) { > sapply(vector.of.variable.names, function(x) get(x)) >} Even better :-) -- Hans Ekbrand (http://sociologi.cjb.net) GPG Fingerprint: 1408 C8D5

Re: [R] how to make list() return a list of *named* elements

2010-10-04 Thread Hans Ekbrand
On Mon, Oct 04, 2010 at 07:45:23PM +0800, Berwin A Turlach wrote: > G'day Hans, > > On Mon, 4 Oct 2010 11:28:15 +0200 > Hans Ekbrand wrote: > > > On Thu, Sep 30, 2010 at 09:34:26AM -0300, Henrique Dallazuanna wrote: > > > You should try: > > &g

[R] how to make list() return a list of *named* elements

2010-09-30 Thread Hans Ekbrand
elements? I often use list() in return(), and I am getting tired of having to repeat myself. -- Hans Ekbrand (http://sociologi.cjb.net) A. Because it breaks the logical sequence of discussion Q. Why is top posting bad? signature.asc Description: Digital signature __

Re: [R] getting random integers

2010-04-30 Thread Hans Ekbrand
ted. > I'd use instead: > > hist(sample(1:10, 100, replace=TRUE)) sample() is what I want, thank you. -- Hans Ekbrand (http://sociologi.cjb.net) signature.asc Description: Digital signature __ R-help@r-project.org mailing list ht

[R] getting random integers

2010-04-29 Thread Hans Ekbrand
I want 100 integers. Each integer, x, can be in the range 1 =< x => 10. Does the following code give 1 and 10 the same chances to be selected as 2:8? round(runif(100, min = 1, max = 10)) -- Hans Ekbrand signature.asc Description: Digital sig

Re: [R] how to word-wrap text in labels in plots?

2009-04-29 Thread Hans Ekbrand
Thanks to Jim and Eik! I really appreciate your help, and I think can use your suggestions and perhaps write a wrapper for plot that integrates them. -- Hans Ekbrand (http://sociologi.cjb.net) Q. What is that strange attachment in this mail? A. My digital signature, see www.gnupg.org for info

[R] how to word-wrap text in labels in plots?

2009-04-29 Thread Hans Ekbrand
;factor") plot(c) Is there a way to get the long variable labels to automatically wrap so that all labels can be shown? Alternatively, is there a way to get the labels truncated, possibly with ".." appended? -- Hans Ekbrand (http://sociologi.cjb.net) Q. What is that strange att

Re: [R] stata ==> R - error messages

2009-04-24 Thread Hans Ekbrand
rklein <- read.dta("C:\Rklein.dta") -- Hans Ekbrand (http://sociologi.cjb.net) GPG Fingerprint: 1408 C8D5 1E7D 4C9C C27E 014F 7C2C 872A 7050 614E signature.asc Description: Digital signature __ R-help@r-project.org mailing list https://stat.ethz.ch

Re: [R] deleting rows provisionally

2009-04-24 Thread Hans Ekbrand
not saved, it is deleted when the loop enters the next iteration. To actually *modify* answer3 you can use: answer3 <- answer3[-i] -- Hans Ekbrand (http://sociologi.cjb.net) Q. What is that strange attachment in this mail? A. My digital signature, see www.gnupg.org for info on how you could

Re: [R] read.spss, locale and encodings

2009-04-08 Thread Hans Ekbrand
code = "latin1") > Sys.setlocale("LC_CTYPE", lc) > > -- which doesn't strike me as particularly logical, but whatever works THANKS a lot Peter! This works perfectly! I had been struggling with this problem way too long... -- Hans Ekbrand (http://sociologi.cjb

Re: [R] read.spss, locale and encodings

2009-04-08 Thread Hans Ekbrand
On Wed, Apr 08, 2009 at 04:17:51PM +0200, Peter Dalgaard wrote: > Hans Ekbrand wrote: >> Someone running foreign 8.34 that is willing to test my SPSS-file? > > Someone with an SPSS file problem willing to help test the prereleases? :-) http://sociologi.cjb.net/temp/test.sav -

Re: [R] read.spss, locale and encodings

2009-04-08 Thread Hans Ekbrand
On Wed, Apr 08, 2009 at 03:03:06PM +0200, Peter Dalgaard wrote: > Hans Ekbrand wrote: >> I must be missing something obvious here: >> >> According to the help page for read.spss, the reencode option is only >> active when R is run under a UTF-8 locale. > > Not in

[R] read.spss, locale and encodings

2009-04-08 Thread Hans Ekbrand
o.sav") : error reading system-file header In addition: Warning message: In read.spss("wo.sav") : wo.sav: position 143: Variable name begins with invalid character This is under Debian GNU/Linux, the stable release. foreign is version 8.27 -- Hans Ekbrand (http://sociologi.cjb.net) G

Re: [R] Student

2009-04-08 Thread Hans Ekbrand
m uno[1] > one.and.a.half <- uno[1] > one.and.a.half $x [1] 5 Or, if you *really* want what that printed output from test(matrice), create a class for your list-object, and add a special print method, that will only print the first item of the list. -- Hans Ekbrand (http://sociologi

[R] Converting a whole dataframe (including attributes) from latin1 to UTF-8

2009-04-07 Thread Hans Ekbrand
ecognized as such by read.spss (and/or not defined as such in SPSS, but since SPSS respects the numeric values of the factors anyway, users don't need to) Rather than hack around b) too, I wonder if anyone on the list know how to convert a whole data.frame from latin1 encoding to utf8?

Re: [R] PCA and categorical data

2009-03-06 Thread Hans Ekbrand
ook at the results of > > RSiteSearch("correspondence") I can recommend the packages "ca" and "FactoMineR" http://cran.r-project.org/web/packages/ca/index.html http://cran.r-project.org/web/packages/FactoMineR/index.html http://www.jstatsoft.org/v20/i03

Re: [R] frequency table for multiple variables

2009-02-17 Thread Hans Ekbrand
On Tue, Feb 17, 2009 at 10:00:40AM -0600, Marc Schwartz wrote: > on 02/17/2009 09:06 AM Hans Ekbrand wrote: > > Hi r-help! > > > > Consider the following data-frame: > > > >var1 var2 var3 > > 1 314 > > 2 223 > > 3

[R] frequency table for multiple variables

2009-02-17 Thread Hans Ekbrand
var2 1 3 1 2 0 var3 0 0 4 1 1 TIA, -- Hans Ekbrand (http://sociologi.cjb.net) Q. What is that strange attachment in this mail? A. My digital signature, see www.gnupg.org for info on how you could use it to ensure that this mail is from me and has not been altered on the way to you

Re: [R] Pros and Cons of R

2008-05-22 Thread Hans Ekbrand
e > >and delete / un-install the old version > > ummm -- this is of course a function of the package manager > and operating system being used, and not of R intrinsicly; > under an RPM package manager, this issue is not present Neither under .deb based OS:es such as Ubu

Re: [R] howto import .xls and .ods

2008-05-11 Thread Hans Ekbrand
ndocument. spreadsheet Developed by Sun Microsystems, OASIS Type of formatSpreadsheet Extended fromXML -- Hans Ekbrand (http://sociologi.cjb.net) <[EMAIL PROTECTED]> GPG Fingerprint: 1408 C8D5 1E7D

Re: [R] Get inside a function the name of a variable called as argument?

2008-04-29 Thread Hans Ekbrand
= my_title) Functions should be general, and relying on the name of the variable makes your function less general. What if you in the future want to use plot_function with an anynmous vector created dynamically? e.g by combining two other vectors: plot_function(c(foo, bar)) -- Hans Ekbrand (htt

Re: [R] grouped colSums without for loops?

2008-03-18 Thread Hans Ekbrand
On Tue, Mar 18, 2008 at 12:05:23PM +0100, Albert Greinoecker wrote: > try: > aggregate(d[,2:3], by=list(d$foo), FUN=sum) Great! Now I can get a data.frame as well as a list, thanks! -- Hans Ekbrand (http://sociologi.cjb.net) <[EMAIL PROTECTED]> Signature generated by Signify

Re: [R] grouped colSums without for loops?

2008-03-18 Thread Hans Ekbrand
On Tue, Mar 18, 2008 at 05:57:59AM -0500, jim holtman wrote: > Is this what you want? > > > lapply(split(d, d$foo), function(x) colSums(x[,-1])) Yes! Thank you! the *apply functions seem very powerful, thanks again for giving me a hint on how to use them. -- Hans E

[R] grouped colSums without for loops?

2008-03-18 Thread Hans Ekbrand
t have d$foo == "a" I know I can use colSums(subset(d, d[[1]] == "a", select = 2)) But what is needed to get a list of colSums for d[[2]] for each factor of d$foo ? Can it be done without a for loop? -- Hans Ekbrand (http://sociologi.cjb.net) <[EMAIL PROTEC

Re: [R] problems with rgl in Ubuntu 'gutsy'

2008-03-18 Thread Hans Ekbrand
t; And a windows with moving gears appears, and it has a frame. But it doesn't > click and drag easily. On my system that window can be moved and even resized without problems (keeping a high rendering rate). Sorry, but I my test didn't give any conclusive new facts about the cause of the

Re: [R] problems with rgl in Ubuntu 'gutsy'

2008-03-17 Thread Hans Ekbrand
sudo apt-get install r-cran-rgl' ? Does X do gl-rendering OK with other applications? (what does $ glxgears -info give you?) -- Hans Ekbrand (http://sociologi.cjb.net) <[EMAIL PROTECTED]> A. Because it breaks the logical sequence of discussion Q. Why is top posting bad? sign

Re: [R] hclust graphics - plotting many points

2008-03-11 Thread Hans Ekbrand
ow other people. Don't you have the problem of too small distances in the X11() window? I've had similar problems with a graph in graphviz, where I found it easier to get what I wanted using a png-driver instead of postscript driver. Png doesn't scale well, but it might be worth a

Re: [R] Plot using colors

2008-03-03 Thread Hans Ekbrand
n','red')) > this works well! > > But since I add a type="l" to my plot, it will color all the plot with > green!!! Please include this too. -- Hans Ekbrand (http://sociologi.cjb.net) <[EMAIL PROTECTED]> GPG Fingerprint: 1408 C8

Re: [R] simple usage of "for"

2008-02-19 Thread Hans Ekbrand
On Tue, Feb 19, 2008 at 10:04:13AM -0500, Duncan Murdoch wrote: > On 2/19/2008 9:24 AM, Hans Ekbrand wrote: [...] > > I tried the following small code snippet which I copied from the > > "Introduction to R": > > > >> for (i in 2:length(meriter)) { table(

Re: [R] simple usage of "for"

2008-02-19 Thread Hans Ekbrand
On Tue, Feb 19, 2008 at 04:52:19PM +0200, K. Elo wrote: > Hi, > > Hans Ekbrand wrote (19.2.2008): > > I tried the following small code snippet which I copied from the > > > > "Introduction to R": > > > for (i in 2:length(meriter)) { table(meriter

[R] simple usage of "for"

2008-02-19 Thread Hans Ekbrand
output at all, just a new prompt. I added a print statement just to check the loop construct, and it seems to work. > for (i in 2:length(meriter)) { print(i); table(meriter[[1]], meriter[[i]]) } [1] 2 [1] 3 [1] 4 But I get no tables :-( What do I do wrong? -- Hans Ekbrand (http://sociolo

[R] Solution: ploting a comparison of two scores, including the labels in the plot

2007-11-06 Thread Hans Ekbrand
A )) tmp2 <- rep( c(1,2,NA), nrow(data.frame) ) plot(tmp2, tmp, type='b', xlim=c(0,3), xlab='', ylab='', lwd=0.5) text(0.9, data.frame[[vector1]], data.frame[[vector3]], adj=1, cex=0.75) text(2.1, data.frame[[vector2]], data.frame[[vector3]], adj=0, ce

Re: [R] ploting a comparison of two scores, including the labels in the plot

2007-11-05 Thread Hans Ekbrand
x=0.75) > text(2.1, mydata$INDM, mydata$job, adj=0, cex=0.75) Yes, definately! Thanks Greg, now I'll just increase the smallest differences to a minimum so the labels becomes readable. -- Hans Ekbrand (http://sociologi.cjb.net) <[EMAIL PROTECTED]> A. Because it breaks the logical sequence

Re: [R] ploting a comparison of two scores, including the labels in the plot

2007-11-01 Thread Hans Ekbrand
="") > points(xx2,status[,3]) > segments(xx1,status[,2],xx2,status[,3]) > text(xx1-.1,status[,2], labels=status[,1], cex=.6) > text(xx2+.1, status[,3], labels=status[,1], cex=.6) -- Hans Ekbrand (http://sociologi.cjb.net) <[EMAIL PROTECTED]> Q. What is that stran

[R] ploting a comparison of two scores, including the labels in the plot

2007-11-01 Thread Hans Ekbrand
labels with the points and the two points that represents the occupation. Since there are a lot of functions for ploting and I am new to R, I would like advise on what packages/functions that should be used to get what I want (if what I want is possible to achieve with R, if it is not, then please le