Re: [R] Using different function (parameters) with apply

2013-04-18 Thread andrija djurovic
Hi. It would be easier to help you if you show us the result you are trying to obtain. Here are my attempts: sweep(a,2,div, FUN=/) [,1] [,2] [,3] [1,]1 2.0 2.33 [2,]2 2.5 2.67 [3,]3 3.0 3.00 or a/matrix(rep(div,3),ncol=3, byrow=TRUE) [,1] [,2]

Re: [R] Using different function (parameters) with apply

2013-04-18 Thread Berend Hasselman
On 18-04-2013, at 07:20, Sachinthaka Abeywardana sachin.abeyward...@gmail.com wrote: Hi All, I have the following problem (read the commented bit below): a-matrix(1:9,nrow=3) a [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 div-1:3

Re: [R] Using different function (parameters) with apply

2013-04-18 Thread David Winsemius
On Apr 17, 2013, at 10:20 PM, Sachinthaka Abeywardana wrote: Hi All, I have the following problem (read the commented bit below): a-matrix(1:9,nrow=3) a [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 div-1:3 apply(a,2,function(x)x/div)

[R] How can I ask R to skip the title when reading the data?

2013-04-18 Thread jpm miao
I have many xls grade report sheets with the same format XXX High School Grade Report Confidential Yes Math English Science John 90 85 90 Mary 75 88 93 …… Since the reports are prepared on a regular basis, I have many reports with identical format. Without the title “XXX High

Re: [R] How can I ask R to skip the title when reading the data?

2013-04-18 Thread andrija djurovic
Hi. You can try with argument skip in read.csv function(check ?read.csv). Also, if you want directly to import an Excel file you can use readWorksheet function from XLConnect package and use argument startRow to set up the first row to read from. Hope this helps. Andrija On Thu, Apr 18, 2013

Re: [R] How can I ask R to skip the title when reading the data?

2013-04-18 Thread Pascal Oettli
Hi, You didn't read the help file carefully enough. ?read.csv skip argument. Regards, Pascal On 04/18/2013 04:46 PM, jpm miao wrote: I have many xls grade report sheets with the same format XXX High School Grade Report Confidential Yes Math English Science John 90 85 90 Mary

[R] Subsetting a large number into smaller numbers and find the largest product

2013-04-18 Thread Janesh Devkota
Hello, I have a big number lets say of around hundred digits. I want to subset that big number into consecutive number of 5 digits and find the product of those 5 digits. For example my first 5 digit number would be 73167. I need to check the product of the individual numbers in 73167 and so on.

[R] snow: cluster initialization

2013-04-18 Thread Kaiyin Zhong (Victor Chung)
Dear all, I found a strange thing with the snow package. This will work: y = matrix(1:4, 2) cl = makeCluster(rep('localhost', 8), type='SOCK') parMM(cl, y, y) This will not: y = matrix(1:4, 2) ncore = system('nproc') parMM(cl, y, y) Error in cut.default(i, breaks) : invalid number of intervals

Re: [R] Subsetting a large number into smaller numbers and find the largest product

2013-04-18 Thread Ted Harding
On 18-Apr-2013 08:47:18 Janesh Devkota wrote: Hello, I have a big number lets say of around hundred digits. I want to subset that big number into consecutive number of 5 digits and find the product of those 5 digits. For example my first 5 digit number would be 73167. I need to check the

[R] parSapply can't find function

2013-04-18 Thread Kaiyin Zhong (Victor Chung)
Here is the code, assuming 8 cores in the cpu. library('modeest') library('snow') cl = makeCluster(rep('localhost', 8), 'SOCK') x = vector(length=50) x = sapply(x, function(i) i=sample(c(1,0), 1)) pastK = function(n, x, k) { if (nk) { return(x[(n-k):(n-1)]) } else {return(NA)} } predR

Re: [R] Subsetting a large number into smaller numbers and find the largest product

2013-04-18 Thread Jorge I Velez
Dear Janesh, Here is one way: # note x is a character x - 73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557 k - nchar(x) # digits in x b - 5 #

Re: [R] t-statistic for independent samples

2013-04-18 Thread peter dalgaard
On Apr 18, 2013, at 05:35 , Thomas Lumley wrote: I just looked more carefully at your code. You are computing the unequal-variance (Welch) version of the t-test, so that's why there isn't a problem. Compare it with the equal-variance t-test, using the pooled variance estimate, which does

Re: [R] Subsetting a large number into smaller numbers and find the largest product

2013-04-18 Thread andrija djurovic
Hi. Here is one approach: options(scipen=300) numb - 73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557 strsplit(as.character(numb), ) blocks -

[R] dividing a long column to many short ones by a condition

2013-04-18 Thread Igor Mintz
hello i have a very long column of numbers. i want R to make a new column every time the value changes from zero. example for the column: 90.1194354 87.94788274 80.34744843 64.06080347 30.40173724 0 0 0 0 0 16.28664495 23.88707926 29.31596091 48.85993485 13.02931596 0 0 0 7.600434311 20.62975027

Re: [R] mgcv: how select significant predictor vars when using gam(...select=TRUE) using automatic optimization

2013-04-18 Thread Jan Holstein
Simon, thanks for the reply, I guess I'm pretty much up to date using mgcv 1.7-22. Upgrading to R 3.0.0 also didn't do any change. Unfortunately using method=REML does not make any difference: ### first with select=FALSE fit-gam(target

Re: [R] Memory usage reported by gc() differs from 'top'

2013-04-18 Thread Milan Bouchet-Valat
Le mercredi 17 avril 2013 à 23:17 -0400, Christian Brechbühler a écrit : In help(gc) I read, ...the primary purpose of calling 'gc' is for the report on memory usage. What memory usage does gc() report?  And more importantly, which memory uses does it NOT report?  Because I see one answer from

Re: [R] dividing a long column to many short ones by a condition

2013-04-18 Thread andrija djurovic
Hi Igor. Here is one way: DF - read.table(textConnection(90.1194354 87.94788274 80.34744843 64.06080347 30.40173724 0 0 0 0 0 16.28664495 23.88707926 29.31596091 48.85993485 13.02931596 0 0 0 7.600434311 20.62975027 29.31596091 32.5732899), header=FALSE) a - DF$V1[which(DF$V1!=0)] indx -

Re: [R] dividing a long column to many short ones by a condition

2013-04-18 Thread Rui Barradas
Hello, Something like this? grp - cumsum(abs(c(0, diff(x == 0 tmp - lapply(split(x, grp), function(x) if(all(x == 0)) NULL else x) tmp[sapply(tmp, function(x) !is.null(x))] Hope this helps, Rui Barradas Em 18-04-2013 10:33, Igor Mintz escreveu: hello i have a very long column of

Re: [R] dividing a long column to many short ones by a condition

2013-04-18 Thread Rui Barradas
Hello, Sorry, forgot the instruction to read in the data. Now the complete code. x - scan(text = 90.1194354 87.94788274 80.34744843 64.06080347 30.40173724 0 0 0 0 0 16.28664495 23.88707926 29.31596091 48.85993485 13.02931596 0 0 0 7.600434311 20.62975027 29.31596091 32.5732899 ) x grp -

Re: [R] dividing a long column to many short ones by a condition

2013-04-18 Thread andrija djurovic
Hi. I completely forgot split function so loop: l - vector(list, n_levels) for(i in 1:n_levels) { l[[i]] - a[blocks==levels(blocks)[i]] } l could be substitute with: split(a, blocks), but anyway Rui's solution is better. Andrija On Thu, Apr 18, 2013 at 1:18 PM, andrija djurovic

Re: [R] simulation\bootstrap of list factors

2013-04-18 Thread Adams, Jean
Tobias, I'm not sure if this is what you're after, but perhaps it will help. # create a list of 5 vectors n - 5 subsets - lapply(1:n, function(x) rnorm(5, mean=80, sd=1)) # create another list that takes 2 bootstrap samples from each of the 5 vectors and puts them in a matrix nbootstrap - 2

[R] find lowest AIC of a LM

2013-04-18 Thread Fabio Berzaghi
hello all, I have a simple linear model with 4/5 variables that I am trying to fit. I would like to find the lowest AIC value with any combination of all the variables. I would like to implement this with a while/for loop. Possibly I would like to generalize this so then I can use it when I

Re: [R] Subsetting a large number into smaller numbers and find the largest product

2013-04-18 Thread arun
Hi, You could also use: x - 73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557  

Re: [R] snow: cluster initialization

2013-04-18 Thread Jon Olav Skoien
I dont think this has anything to do with the snow package, you should rather start by checking what is the output of system('nproc') is on your computer, and also whether it is possible to assign this to a variable. I tried on a redhat linux (R 2.15.0) server: ncore = system('nproc') 16

Re: [R] snow: cluster initialization

2013-04-18 Thread Jon Olav Skoien
I also wanted to add the result from my Windows machine (R 3.0.0) to the answer below: ncore = system('nproc') ncore [1] 127 # My machine was not happy about starting a cluster with 127 nodes though. Best wishes, Jon On 18-Apr-13 15:13, Jon Olav Skoien wrote: I dont think this has anything

Re: [R] snow: cluster initialization

2013-04-18 Thread Kaiyin Zhong (Victor Chung)
Thanks. So is there a way to get the number of cpu cores in R? Best regards, Kaiyin ZHONG -- FMB, Erasmus MC k.zh...@erasmusmc.nl kindlych...@gmail.com On Thu, Apr 18, 2013 at 3:18 PM, Jon Olav Skoien jon.sko...@jrc.ec.europa.eu wrote: I also wanted to add the

Re: [R] mgcv: how select significant predictor vars when using gam(...select=TRUE) using automatic optimization

2013-04-18 Thread Simon Wood
Jan, Thanks for this. Is there any chance that you could send me the data off list and I'll try to figure out what is happening? (Under the understanding that I'll only use the data for investigating this issue, of course). best, Simon on 18/04/13 11:11, Jan Holstein wrote: Simon, thanks

Re: [R] snow: cluster initialization

2013-04-18 Thread Kaiyin Zhong (Victor Chung)
ok, got it: library(multicore) ncore = multicore:::detectCores() Best regards, Kaiyin ZHONG -- FMB, Erasmus MC k.zh...@erasmusmc.nl kindlych...@gmail.com On Thu, Apr 18, 2013 at 3:13 PM, Jon Olav Skoien jon.sko...@jrc.ec.europa.eu wrote: I dont think this has

Re: [R] snow: cluster initialization

2013-04-18 Thread Prof Brian Ripley
On 18/04/2013 14:22, Kaiyin Zhong (Victor Chung) wrote: Thanks. So is there a way to get the number of cpu cores in R? Yes, for various definitions of 'core'. Try ??cores which gets you to parallel::detectCores Detect the Number of CPU Cores And BTW 'snow' is not part of R. Best

Re: [R] Memory usage reported by gc() differs from 'top'

2013-04-18 Thread Martin Morgan
On 04/18/2013 03:18 AM, Milan Bouchet-Valat wrote: Le mercredi 17 avril 2013 à 23:17 -0400, Christian Brechbühler a écrit : In help(gc) I read, ...the primary purpose of calling 'gc' is for the report on memory usage. What memory usage does gc() report? And more importantly, which memory uses

Re: [R] Subsetting a large number into smaller numbers and find the largest product

2013-04-18 Thread arun
Hi Janesh, This is a bit shorter: library(seqinr) sapply(split(as.numeric(s2c(x)),((seq(nchar(x))-1)%/%5)+1),prod)   A.K. - Original Message - From: arun smartpink...@yahoo.com To: Janesh Devkota janesh.devk...@gmail.com Cc: R help r-help@r-project.org Sent: Thursday, April 18, 2013

Re: [R] vectors with equal values

2013-04-18 Thread arun
Hi, Try:  vec1-c(1,1,1,1,1,1,1,1,1) if(all(vec1==1)) x else  yyy #[1] x  vec2-c(rep(1,4),2)  if(all(vec2==1)) x else  yyy #[1] yyy #or if(length(unique(vec1))==1) x else  yyy #[1] x   if(length(unique(vec2))==1) x

Re: [R] Create a function for test the data

2013-04-18 Thread arun
Hi, You didnt provide an example dataset: set.seed(25) mycd- data.frame(a_vol3=sample(1:20,20,replace=TRUE),a_vol4=sample(5:45,20,replace=TRUE),week=rep(1:4,each=5))  aggregate(a_vol3 ~ week , data = mycd, mean)  aggregate(a_vol4 ~ week , data = mycd, mean)  #The above two could be combined to:  

Re: [R] vectors with equal values

2013-04-18 Thread arun
Hi, Isn't that answered already? vec2-c(2,2,2,2,2,2,2)   if(length(unique(vec2))==1) x else  yyy #[1] x vec2-c(22,22,22,22,23,22,22)   if(length(unique(vec2))==1) x else  yyy #[1] yyy  vec2-c(22,22,22,22,22,22,22)   if(length(unique(vec2))==1)

[R] Statistical test for heteroscedasticity for an object of class gls

2013-04-18 Thread Benjamin Gillespie
Hi there, Does anyone know of a statistical test for heteroscedasticity for an object of class gls? (or alternative objective methods). Thanks in advance, Ben Gillespie, Research Postgraduate o---o School of Geography, University

Re: [R] Singular design matrix in rq

2013-04-18 Thread William Dunlap
Do you know that there are NaN's in the output of bs(raw_data[,i],df=15)? any(is.nan(bs(raw_data[,i],df=15))) would tell you. Do you know that there are fewer than c. 18 distinct values in raw_data[,i]? length(unique(raw_data[,i])) would tell you. If there are not very many distinct values

Re: [R] Statistical test for heteroscedasticity for an object of class gls

2013-04-18 Thread Benjamin Gillespie
Also, out of interest, does anyone know of a test (or objective method) for spatial autocorrelation for gls objects? Thanks, Ben Gillespie, Research Postgraduate o---o School of Geography, University of Leeds, Leeds, LS2 9JT

Re: [R] positioning of R windows

2013-04-18 Thread Glenn Stauffer
I said I would post if I figured this out - here is what I found. When my working directory is located anywhere within my user folder (e.g. C/Users/Stauffer) on my Windows 7 computer, then the Browse for folder dialog box displays the behavior I described (directory tree always defaults to My

Re: [R] mgcv: how select significant predictor vars when using gam(...select=TRUE) using automatic optimization

2013-04-18 Thread Simon Wood
Jan, Thanks for the data (off list). The p-value computations are based on the approximation that things are approximately normal on the linear predictor scale, but actually they are no where close to normal in this case, which is why the p-values look inconsistent. The reason that the

[R] OFFTOPIC: Ioannidis et. al. on non-reproducible research

2013-04-18 Thread Bert Gunter
OFFTOPIC These links were sent to me by a friend and are kind of a followup to Sarah Goslee's recent off topic post on the Rogoff Excel spreadsheet goof, which I appreciated, that I hope will be of interest to this list's readers. I apologize if I have taken too much license. I will

[R] Arranging two different types of ggplot2 plots with axes lined up

2013-04-18 Thread Saalem Adera
Hi all, I want to arrange two ggplot2 plots on the same page with their x-axes lined up - even though one is a boxplot and the other is a line plot. Is there a simple way to do this? I know I could do this using facetting if they were both the same type of plot (for example, if they were both

Re: [R] find lowest AIC of a LM

2013-04-18 Thread Ben Bolker
Fabio Berzaghi fabe at dmu.dk writes: hello all, I have a simple linear model with 4/5 variables that I am trying to fit. I would like to find the lowest AIC value with any combination of all the variables. I would like to implement this with a while/for loop. Possibly I would like to

Re: [R] Optimisation and NaN Errors using clm() and clmm()

2013-04-18 Thread Thomas Foxley
Rune, Thank you very much for your response. I don't actually have the models that failed to converge from the first (glmulti) part as they were not saved with the confidence set. glmulti generates thousands of models so it seems reasonable that a few of these may not converge. The clmm()

Re: [R] Arranging two different types of ggplot2 plots with axes lined up

2013-04-18 Thread Andrés Aragón Martínez
Hi Saalem, Check the following: http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/ Regards, Andrés AM El 18/04/2013, a las 09:47, Saalem Adera saalemad...@gmail.com escribió: Hi all, I want to arrange two ggplot2 plots on the same page with their x-axes lined up -

Re: [R] Creating %d/%m/%Y %H:%M:%S format from separate date andtimecolumns

2013-04-18 Thread MacQueen, Don
I know this is a late response, but what about startt - as.POSIXct( paste(data2$V4, data2$V5) ) endt - startt + data2$V6 -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 4/12/13 12:09 AM, Cat Cowie

Re: [R] select and do some calculations/manipulations on certain rows based on conditions in R

2013-04-18 Thread arun
Hi, May be this helps (Assuming that there are only '0's and '1's in the dataset) dat1-read.table(text=     ID X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 1   5184    0    0    0    0    0   0   0    0    0    1 0  0  0   0  0  0 2   6884    0    0    1    0  

Re: [R] Memory usage reported by gc() differs from 'top'

2013-04-18 Thread Kjetil Kjernsmo
On Thursday 18. April 2013 12.18.03 Milan Bouchet-Valat wrote: First, completely stop looking at virtual memory: it does not mean much, if anything. What you care about is resident memory. See e.g.: http://serverfault.com/questions/138427/top-what-does-virtual-memory-size-m ean-linux-ubuntu I

Re: [R] Splitting vector

2013-04-18 Thread arun
Hi, Try: vec1- mue#d/sjbijk@ruepvnvbnceiicrpgxkgcyl@keduhqvqi/ubudvxopddpfddgitrynzshzdcwgneyffrkpbxwilwqngrsals#geqmtkcpkp/qecgdfa#uag library(seqinr)  res-lapply(0:4,function(i) lapply(2:5,function(j) splitseq(s2c(gsub([#@/],,vec1)),word=j,frame=i))) #or library(stringr)

[R] MANN

2013-04-18 Thread Gilson Carvalho
Dear all, Is there a package in R that has implemented the MANN (Multiresponse Artificial Neural Network) presented in (Olden, 2006 - Ecological Applications)? Best Wishes, -- Prof. Gilson Correia de Carvalho, M.Sc. Pesquisador Associado

Re: [R] count values

2013-04-18 Thread arun
 vec1- c(0,1,1,1,2,2,2,3,3) length(unique(vec1[vec1!=0])) #[1] 3  vec2- c(0,2,2,3)  length(unique(vec2[vec2!=0])) #[1] 2 A.K. Hi. I have a new question. I need count the different numbers in a vector,but different of zero. I mean,if I have c(0,2,2,3) the result is 2. If the  vector is

[R] texi2pdf texinputs arguments

2013-04-18 Thread Duncan Mackay
Dear All I am trying to specify the output directory and the directory for the log files (the same) for texi2dvi. The default for my windows computer is C:\Users\...\Documents which I do not want. The help guide: texinputs NULL or a character vector of paths to add to the LaTeX and bibtex

[R] How to keep plot title same as column name using apply/sapply?

2013-04-18 Thread C W
Dear list, I am trying to plot histogram of a 10 by 5 matrix by columns. What is a good way to paste the column names? dput(a) structure(c(0.891856482875103, 0.249593821948295, 0.0385066520473322, 0.109098868876336, 0.238035894186719, 0.971470380855763, 0.168018536530906, 0.941457062296419,

Re: [R] texi2pdf texinputs arguments

2013-04-18 Thread Henrik Bengtsson
I'm pretty sure the intended design is to always use the current working directory as the output directory, cf. 'Value' section in help(texi2dvi, package=tools): Used for the side effect of creating a dvi or PDF file in the current working directory (and maybe other files, especially if clean =

Re: [R] How to keep plot title same as column name using apply/sapply?

2013-04-18 Thread Bert Gunter
Note that in: apply(a,2,function(x){colnames(x)}) x is a vector, and therefore has no column names. -- Bert On Thu, Apr 18, 2013 at 3:30 PM, C W tmrs...@gmail.com wrote: Dear list, I am trying to plot histogram of a 10 by 5 matrix by columns. What is a good way to paste the column names?

[R] count each answer category in each column

2013-04-18 Thread Ye Lin
Hey, Is it possible that R can calculate each options under each column and return a summary table? Suppose I have a table like this: Gender Age Rate Female0-10 Good Male0-10 Good Female 11-20 Bad Male 11-20 Bad Male 20 N/A I want to have a summary

Re: [R] How to keep plot title same as column name using apply/sapply?

2013-04-18 Thread arun
Hi, Try:  par(mfrow=c(3, 2)) mapply(hist,as.data.frame(a),main=colnames(a),xlab=x) A.K. - Original Message - From: C W tmrs...@gmail.com To: r-help r-help@r-project.org Cc: Sent: Thursday, April 18, 2013 6:30 PM Subject: [R] How to keep plot title same as column name using

Re: [R] How to keep plot title same as column name using apply/sapply?

2013-04-18 Thread arun
#or par(mfrow=c(3,2))  sapply(seq_len(ncol(a)),function(i) hist(a[,i],main=colnames(a)[i],xlab=x)) A.K. - Original Message - From: arun smartpink...@yahoo.com To: C W tmrs...@gmail.com Cc: R help r-help@r-project.org Sent: Thursday, April 18, 2013 6:49 PM Subject: Re: [R] How to keep

Re: [R] How to keep plot title same as column name using apply/sapply?

2013-04-18 Thread C W
Thanks, Bert and Arun! Arun, I've always struggled with the difference between sapply/mapply/tapply, thanks for the two very elegant examples. Very helpful! :) Mike On Thu, Apr 18, 2013 at 6:52 PM, arun smartpink...@yahoo.com wrote: #or par(mfrow=c(3,2)) sapply(seq_len(ncol(a)),function(i)

Re: [R] count each answer category in each column

2013-04-18 Thread arun
Hi, Try this: Assuming that table is data.frame dat1-read.table(text= Gender  Age  Rate Female    0-10  Good Male    0-10  Good Female    11-20  Bad Male    11-20  Bad Male    20    N/A ,sep=,header=TRUE,stringsAsFactors=FALSE,na.strings=N/A) lapply(seq_len(ncol(dat1)),function(i)

[R] trouble with write.foreign

2013-04-18 Thread cmk087
I am trying to write a 1x8 matrix into a text file so I can read it into SAS. When I tried using write.table I could not get just 8 columns and 1 rows it would just write all the data in a line until it hit the end and went to the next line. I tried instead using write.foreign and I got an

[R] Multiple Multivariate regression in R with 50 independent variables

2013-04-18 Thread Nilesh Gupta
Hello all Is there a method/package in R in which I can do regressions for more than 50 independent variables ? Regards The woods are lovely, dark and deep But I have promises to keep And miles before I go to sleep And miles before I go to sleep - [[alternative HTML version

Re: [R] trouble with write.foreign

2013-04-18 Thread Sarah Goslee
Hi, On Thursday, April 18, 2013, cmk087 wrote: I am trying to write a 1x8 matrix into a text file so I can read it into SAS. When I tried using write.table I could not get just 8 columns and 1 rows it would just write all the data in a line until it hit the end and went to the

Re: [R] How to keep plot title same as column name using apply/sapply?

2013-04-18 Thread C W
mapply(hist,as.data.frame(a),main=colnames(a),xlab=x) Why it does't work when I use a instead of as.data.frame(a)? ?mapply says arguments to vectorize over (vectors or lists of strictly positive length, or all of zero length). Thanks, Mike On Thu, Apr 18, 2013 at 6:49 PM, arun

Re: [R] count each answer category in each column

2013-04-18 Thread David Winsemius
On Apr 18, 2013, at 3:46 PM, Ye Lin wrote: Hey, Is it possible that R can calculate each options under each column and return a summary table? Suppose I have a table like this: Gender Age Rate Female0-10 Good Male0-10 Good Female 11-20 Bad Male

Re: [R] count each answer category in each column

2013-04-18 Thread Jim Lemon
On 04/19/2013 08:46 AM, Ye Lin wrote: Hey, Is it possible that R can calculate each options under each column and return a summary table? Suppose I have a table like this: Gender Age Rate Female0-10 Good Male0-10 Good Female 11-20 Bad Male 11-20 Bad Male20

Re: [R] trouble with write.foreign

2013-04-18 Thread David Winsemius
On Apr 18, 2013, at 2:39 PM, cmk087 wrote: I am trying to write a 1x8 matrix into a text file so I can read it into SAS. When I tried using write.table I could not get just 8 columns and 1 rows it would just write all the data in a line until it hit the end and went to the next

Re: [R] How to keep plot title same as column name using apply/sapply?

2013-04-18 Thread arun
Hi, You can try:   par(mfrow=c(3, 2))  mapply(hist,split(a,col(a)),main=colnames(a),xlab=x) If you look at the output, mapply(hist,a,main=colnames(a),xlab=x) [,1]   [,2]   [,3]  breaks   Numeric,2  Numeric,2  Numeric,2

Re: [R] count each answer category in each column

2013-04-18 Thread arun
If the format is not a problem, you could also use: dat1-read.table(text= Gender  Age  Rate Female    0-10  Good Male    0-10  Good Female    11-20  Bad Male    11-20  Bad Male    20    N/A ,sep=,header=TRUE) res-summary(dat1) res  #   Gender Age  Rate   #Female:2   0-10 :2  

Re: [R] How to keep plot title same as column name using apply/sapply?

2013-04-18 Thread C W
I agree! I would have thought of using as.data.frame() no matter how hard I had to think. ;) Thanks, Mike On Thu, Apr 18, 2013 at 10:18 PM, arun smartpink...@yahoo.com wrote: Hi, You can try: par(mfrow=c(3, 2)) mapply(hist,split(a,col(a)),main=colnames(a),xlab=x) If you look at the

Re: [R] How to keep plot title same as column name using apply/sapply?

2013-04-18 Thread Bert Gunter
Have you read the Intro to R tutorial or checked the relevant parts of the R Language Definition.? Had you done so, I think you would have found in one or the other or both that a matrix is just a vector with a dim attribute. mapply() just sees that single argument -- a vector of length 50. The

[R] Standard Error and P-Value from cor()

2013-04-18 Thread Gundala Viswanath
Is there a native way to produce SE of correlation in R's cor() functions and p-value from T-test? As explained in this web http://www.sjsu.edu/faculty/gerstman/StatPrimer/correlation.pdf (page 14.6) The standard error is sqrt((1-r^2)/(n-2)), where n- is the number of sample. - G.V.

[R] How to read a direct access file by connecting fortran with R ?

2013-04-18 Thread Kaptue Tchuente, Armel
Hello all, I would like to read the specific line number row of a direct access file (which is stored as a n_row*n_col matrix of elements kind=p) without reading all the preceding lines (i.e 1,2,..,row-1). Is there a function in R that can perform this task? To solve my issue, I tried without

Re: [R] Standard Error and P-Value from cor()

2013-04-18 Thread Pascal Oettli
Hi, ?cor.test Regards, Pascal 2013/4/19 Gundala Viswanath gunda...@gmail.com Is there a native way to produce SE of correlation in R's cor() functions and p-value from T-test? As explained in this web http://www.sjsu.edu/faculty/gerstman/StatPrimer/correlation.pdf (page 14.6) The