Re: [R] Apply a multi-variable function to a vector

2016-09-12 Thread Stephen Kennedy
18 21 > # > # , , C = 4 > # > #B > # A2 3 4 5 6 > # 1 6 7 8 9 10 > # 2 8 10 12 14 16 > # 3 10 13 16 19 22 > > I generally just tack on columns to the expand.grid result... I almost > never have a need for multidimensional arrays. > > On

Re: [R] Apply a multi-variable function to a vector

2016-09-10 Thread Stephen Kennedy
, C = 3 > # > #B > # A 2 3 4 5 6 > # 1 5 6 7 8 9 > # 2 7 9 11 13 15 > # 3 9 12 15 18 21 > # > # , , C = 4 > # > #B > # A2 3 4 5 6 > # 1 6 7 8 9 10 > # 2 8 10 12 14 16 > # 3 10 13 16 19 22 > > I generally just

[R] Apply a multi-variable function to a vector

2016-09-09 Thread Stephen Kennedy
of variables? I’d like something that would simply work from the definition of the function. If that is possible. Thanks, Steve Kennedy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and mo

[R] Apply a multi-variable function to a vector

2016-09-09 Thread Steve Kennedy
s? I'd like something that would simply work from the definition of the function. If that is possible. Thanks, Steve Kennedy CONFIDENTIALITY NOTICE: This e-mail message, including a...{{dropped:11}} __ R-help@r-project.org mailing list -- To UN

Re: [R] power.t.test threading on 'power'

2014-10-03 Thread Stephen Kennedy
eve Stephen J. Kennedy, Ph.D. Director, Research & Development Prollenium Medical Technologies, Inc. 138 Industrial Parkway North Aurora, ON L4G 4C3 Canada +1 (905) 508-1469 X223 step...@prollenium.com On Oct 1, 2014, at 6:46 PM, peter dalgaard wrote: On 01 Oct 2014, at 14:29 , Stephen Kennedy

Re: [R] power.t.test threading on 'power'

2014-10-01 Thread Stephen Kennedy
Oct 1, 2014, at 6:46 PM, peter dalgaard wrote: On 01 Oct 2014, at 14:29 , Stephen Kennedy wrote: > Simple question. A vector of ‘number of observations’ can be input to > power.t.test, and a vector of ‘power’ s is output. But, inputting a vector > of powers generates an err

Re: [R] power.t.test threading on 'power'

2014-10-01 Thread Stephen Kennedy
Kennedy wrote: > Simple question. A vector of ‘number of observations’ can be input to > power.t.test, and a vector of ‘power’ s is output. But, inputting a vector > of powers generates an error. Am I missing something? > > Vector of ’n’ s > > power.t.test(n=c(28,

[R] power.t.test threading on 'power'

2014-10-01 Thread Stephen Kennedy
Simple question. A vector of ‘number of observations’ can be input to power.t.test, and a vector of ‘power’ s is output. But, inputting a vector of powers generates an error. Am I missing something? Vector of ’n’ s power.t.test(n=c(28,29,30), delta=2, sd=3, sig.level=0.05, type="two.sample",

[R] I am new to R

2014-02-13 Thread Shikami Kennedy
Hello there, I am new to R and have no previous experience using any other statistics software. Can someone send me basic R notes to help me start off for the very first time? *With Kind regards,* * God bless you* * Shikami K. Akweyu Manager; Fisheries ComponentKenya Coastal Development Proj

Re: [R] string manipulation

2011-08-25 Thread Steven Kennedy
You can split your string, and then only take the first 4 digits after that (this is only an improvement if your numbers might not be at the end of mytext): mytext <- "I do not want the first number 1234, but the second number 5678" sstr<-strsplit(mytext,split="second number ")[[1]][2] nynumbers<-

Re: [R] trouble installing packages on OpenSuse 11.4

2011-08-21 Thread Steven Kennedy
I have similar problems when trying to install packages while at work. It might have something to do with your firewall settings. On Wed, Aug 17, 2011 at 4:38 AM, Dinesh wrote: > Hi, > > I am trying to install a bunch of packages via command line and can use > some help in getting it right. My e

Re: [R] a Question regarding glm for linear regression

2011-08-19 Thread Steven Kennedy
convert your matrix to a data frame: df <- as.data.frame(mymatrix) then you can simplify your formula and specify where the data is coming from: glm.fit <- glm(y~., data=df) the "." in the formula means all columns in your dataframe (except "y", if it is in df) On Sat, Aug 20, 2011 at 10:43 A

Re: [R] linear regression

2011-08-13 Thread Steven Kennedy
your dataframe needs to be called "Nord". If it is not, then replace "Nord" with the actual name of your dataframe On Sat, Aug 13, 2011 at 10:43 PM, maggy yan wrote: > dear R users, > my data looks like this > >         PM10       Ref   UZ     JZ         WT   RH   FT   WR > 1   10.973195  4.338

Re: [R] for loop help

2011-07-27 Thread Steven Kennedy
Hi Cassie, I'm not sure exactly what you are trying to get: i assume that each station will have a different ppt value for each year-month combination, but it looks like you're trying to get one ppt value for each station. Steve On Thu, Jul 28, 2011 at 1:30 AM, Wilson, Cassandra J wrote: > I a

Re: [R] Selecting unique values

2011-07-25 Thread Steven Kennedy
use unique() df <- data.frame(Species_name=c(rep('Abies concolor',4),rep('Accipiter cooperi',7)), Longitude=c(-106.601, -106.493, -106.489, -106.496, -119.688, -119.792, -118.797,-77.38333,-77.38333,-75.99153,-75.99153), Latitude=c(35.868, 35.9682, 35.892, 35.85

Re: [R] Deleting rows and store the deleted rows in new data frame

2011-07-24 Thread Steven Kennedy
Hi Vikas, The following works (I'm not very good with sapply, but the for loop is ok if your data set is not huge). > df <- read.table("test.txt",stringsAsFactors=FALSE) > df V1V2 V3 V4 V5 V6 V7 V8 V9 1 10 135349467 g G 4 0 0 5 ,,,., 2 10 135349468 t T 2 0 0 5 ,,c.,

Re: [R] IDE with table/matrix preview

2011-07-18 Thread Steven Kennedy
Try RStudio. It is the best IDE for R I've seen. On Tue, Jul 19, 2011 at 3:31 AM, Michael Bernsteiner wrote: > > I know there are several threads about IDEs for R. > > I've tried Tinn-R, but I am looking for an IDE (win) with a preview function > that shows me the variables and the table/matrix

Re: [R] How to read 20 columns from the file

2011-07-13 Thread Steven Kennedy
Hi Kishore, There should be no problem reading in your data if you have followed the directions posted by Jim and myself. I suggest you do a search for a basic R tutorial and follow that through. Steve On Wed, Jul 13, 2011 at 10:08 PM, Kishorenalluri wrote: > Hi Jim, >        Saving is not a pr

Re: [R] How to read 20 columns from the file

2011-07-13 Thread Steven Kennedy
save it as .csv, then use read.csv("your_file.csv") On Wed, Jul 13, 2011 at 6:23 PM, Kishorenalluri wrote: > Friends, >          Could anyone help me the script, how to read the more than 15 > columns from the file. I have Excel sheet, of course can save into any > readable format. Appreciate you

Re: [R] How to Execute A Query Stored In Access 2007

2011-07-06 Thread Steven Kennedy
You should just be able to use the sqlQuery function to execute the query something like this: con<-odbcConnect(...) sqlQuery(con,"EXEC ") On Thu, Jul 7, 2011 at 11:40 AM, Alex Zhang wrote: > Steven - I use RODBC. Thx, > - Alex > ____ > F

Re: [R] How to Execute A Query Stored In Access 2007

2011-07-06 Thread Steven Kennedy
What package are you using to connect to the Access database? On Thu, Jul 7, 2011 at 7:02 AM, Alex Zhang wrote: > Hey guys, > > Could you please teach me how to run or execute a query stored in an Access > 2007 database? > > I can connect and run queries from my Access database without any prob

Re: [R] Subset creates row_names column when exported to MYSQL

2011-07-06 Thread Steven Kennedy
What function are you using to export your data.frame to MySQL? On Wed, Jul 6, 2011 at 10:41 PM, Thiago Clark wrote: > Dear R-helpers, > > I have a huge dataset and I create a filter selecting only the cases I want > using: >>data <- subset(data, data$var=='x' | data$var=='y' | data$var=='z' |

Re: [R] connecting R and PostgreSQL

2011-06-28 Thread Steven Kennedy
I use RODBC and have got it to work fine on Windows, Linux and Mac. There's some basic info here, and plenty of blog posts out there with step by step instructions for the different OS's. http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/RODBC/html/00Index.html On Tue, Jun 28, 2011 at 11:53 PM

Re: [R] import text-records and set the fields in a table

2011-06-27 Thread Steven Kennedy
As long as all the fields in each entry are the same, then the following will work df<-data.frame(photo_id=NA,owner=NA,secret=NA,server=NA,farm=NA,title=NA, ispublic=NA,isfriend=NA,isfamily=NA,tags=NA) x<-'' y<-strsplit(x,split="=\"") tmp<-c() for (i in 2:length(y[[1]])){ tmp[i-1

Re: [R] Simple simulations

2011-06-27 Thread Steven Kennedy
#sampling elements x<-c(rep(0, 20), seq(1:37)) #number of simulations to perform sims<-100 #vector to store results results<-c() #using for loop to perform simulations for(i in 1:sims){ #take your sample y<-sample(x,3,replace=FALSE) #check if all elements are zero

Re: [R] Fw:

2011-06-26 Thread Steven Kennedy
You can find the volcano script (along with a lot of others) at the following site: http://addictedtor.free.fr/graphiques/thumbs.php On Mon, Jun 27, 2011 at 11:49 AM, Jorge Ivan Velez wrote: > Hi Ungku, > > Check > > ?persp > ?volcano > > in the R console. > > HTH, > Jorge > > > On Sun, Jun 26,

Re: [R] Plotting a gragh or histogram in a certain colour

2011-06-26 Thread Steven Kennedy
plot(1:20,col='blue') On Mon, Jun 27, 2011 at 9:40 AM, wrote: > Dear Sir, > > Just started using R. I want to plot x>-1:20, for example, in the colour > blue. How do I do this? > > Regards, > > Ivo > >        [[alternative HTML version deleted]] > >

Re: [R] converting character to numeric

2011-06-21 Thread Steven Kennedy
You need: mydata$apples<-as.numeric(mydata$apples) On Wed, Jun 22, 2011 at 6:38 AM, Alina Sheyman wrote: > I'm trying to convert data from character to numeric. > >  I've imported data as a csv file, I'm assuming that the import is a > database - are all the columns in  a database considered "ve

Re: [R] analysis with the data from mysql database

2011-06-20 Thread Steven Kennedy
Please tell us the package you are using and the specific commands. It is most likely you are retrieving the data into a list or some other structure that hist() doesn't like. On Mon, Jun 20, 2011 at 12:57 PM, amrita gs wrote: > Hi everyone, > >     I have certain values retrieved from mysql dat

Re: [R] Count occurances in integers (or strings)

2011-06-15 Thread Steven Kennedy
This should work: mydata$my_column<-as.character(mydata$my_column) sum(unlist(strsplit(mydata[,"my_column"], "")) == "1") On Wed, Jun 15, 2011 at 7:09 PM, Jay wrote: > Hi, > > I have a dataframe column from which I want to calculate the number of > 1's in each entry. Some column values could, f

Re: [R] Histogram

2011-06-08 Thread Steven Kennedy
Have a look at: http://addictedtor.free.fr/graphiques/thumbs.php One of the graph examples they have is exactly what you are after. On Wed, Jun 8, 2011 at 11:14 PM, nandini_bn wrote: > > Hello , > I am trying to create a histogram in order to compare between two groups and > would like it to be

Re: [R] Missing completely at random

2011-06-01 Thread Steven Kennedy
This works, but there might be a better way: misscols<-lapply(howmanyMiss, function(x) sample(1:n, x)) for (i in 1:nMiss){ for (j in misscols[[i]]){ X[idMiss[i],j]<-NA } } __ R-help@r-project.org mailing list https://sta

Re: [R] escape characters in shell commands

2011-05-24 Thread Steven Kennedy
As a different approach, you could just use the readLines function: length(readLines(D:\my_dir\my_file)) __ 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-g

Re: [R] RMySQL problem on Windows 7 32 bit

2011-05-13 Thread Steven Kennedy
It looks like your MySQL is missing the libmysql.lib file. Download it from MySQL then put it in the following location: C:/Program Files/MySQL/MySQL Server 5.5/lib/opt/libmysql.lib If you are still having problems, you could try using RODBC instead. _

Re: [R] to check if a group of values is randomly distributed

2011-05-13 Thread Steven Kennedy
try the fitdistr() function in the MASS package __ 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,

Re: [R] Reordering inputs

2011-05-12 Thread Steven Kennedy
On Fri, May 13, 2011 at 1:31 AM, Dat Mai wrote: > Yes, but I want to make it so that 2 different square matrices to both have > the same order for the x and y axis while, at the same time, the x and y > axis having variables in the same order as well: > >   a   b   c d   e 

Re: [R] Reordering inputs

2011-05-11 Thread Steven Kennedy
You can order each matrix by any column you choose like: a<-matrix(rnorm(20),ncol=2) > a[order(a[,1]),] #orders by column 1 [,1] [,2] [1,] -1.86523489 -1.6920270 [2,] -0.94488744 0.2815087 [3,] 0.02380494 0.2491136 [4,] 0.37295795 0.8156993 [5,] 0.55533366 -0.7053233

Re: [R] Converting ordinal dates and time into sensible formats

2011-05-10 Thread Steven Kennedy
How about something like: > data$DateTime<- strptime(paste(data$day.hour,data$min.sec,sep=" > "),format="%j%H %M%S") > data$Date <- strftime(data$DateTime,format="%Y-%m-%d") > data$Time <- strftime(data$DateTime,format="%H:%M:%S") > data day.hour min.secDateTime Date Time

Re: [R] Plotting n a scale up to 6 decimal places

2011-05-08 Thread Steven Kennedy
The plot works fine for me with the example data you have given. Maybe it is something in your par settings. Try putting a ylim in your plot the same as you have done for the xlim: y1<-min(original.estimate) y2<-max(original.estimate) plot(lfdr.true, original.estimate, pch=19, col = "dark red",xli

Re: [R] Insert values to histogram

2011-05-05 Thread Steven Kennedy
Histograms plot data in bins - you don't get the exact value, because each bin contains a range of values. Do you want to plot the range of values the bin contains? Also, check ?hist to see how to set the values of the breaks between the bins. __ R-help@

Re: [R] How to fit a random data into Beta distribution?

2011-05-04 Thread Steven Kennedy
ive us the new parameters of Beta > distribution that approximately fits this data. > > > I have tried the function with other distribution like Normal, Gamma, > Weibull...its working fine.. > > Regards, > Som Shekhar > > > > > On May 4, 1:25 am, Steven Kennedy

Re: [R] How to fit a random data into Beta distribution?

2011-05-03 Thread Steven Kennedy
library(MASS) fitdistr(x,"beta",list(shape1=1,shape2=1)) On Tue, May 3, 2011 at 9:44 PM, Shekhar wrote: > > Hi, > I have some random data and i want to find out the parameters of Beta > distribution ( a and b) such that this data approximately fits into > this distribution. I have tried by plot

Re: [R] INSERT OR UPDATE

2011-05-02 Thread Steven Kennedy
Rather than selecting all the keys, then having R loop through them, why not have postgres do it for you with something like: #go through each line in our entry table for (i in 1:dim(tbl)[1]){ #check if the pkey already exists q <- paste ("SELECT key1, key2 FROM tabl WHERE key1=",tbl[i,1],

Re: [R] subseting data

2011-05-02 Thread Steven Kennedy
You can use grepl: > dat<-data.frame(test=c("abc","cdf","dabc")) > d<-subset(dat,grepl(test,"abc")) > d test 1 abc 3 dabc On Mon, May 2, 2011 at 7:03 PM, Matevž Pavlič wrote: > Hi, > > > > Is it possible (i am sure it is) to subset data from a data.frame on the > basis of SQL >LIKE< oper

Re: [R] Adjusting for autocorrelation in a panel model

2011-02-27 Thread David Kennedy
al message --------- Message: 107 Date: Tue, 22 Feb 2011 16:09:48 +1300 From: "David Kennedy" To: Subject: [R] Adjusting for autocorrelation in a panel model Message-ID: <00b701cbd23d$f7200560$e5601020$@d...@ihug.co.nz> Content-Type: text/plain I am working with

[R] Adjusting for autocorrelation in a panel model

2011-02-21 Thread David Kennedy
I am working with panel data. I am using the plm package to do this. I would like to do be able to adjust for autocorrelation, as one does with glm models and correlation structures (eg corr=corARMA(q=4)) . In particular, I want to employ MA(4) error structure. Is there a way of doing thi

Re: [R] Color individual leaf labels in dendrogram

2010-10-16 Thread Kennedy
Thank you Brian, Your suggestion helped me a bit but I am not quite there yet. Now I have the following code: library(cluster) library(stats) D<-matrix(nr=4,nc=4) rownames(D)<-c("Node 1","Node 2","Node 3","Node 4") D[1,]<-c(0,.6,.1,.7) D[2,]<-c(.6,0,.3,.9) D[3,]<-c(.1,.3,0,.9)

[R] Color individual leaf labels in dendrogram

2010-10-15 Thread Kennedy
Hi, I have performed a clustering of a matrix and plotted the result with pltree. See code below. I want to color the labels of the leafs individually. For example I want the label name "Node 2" to be plotted in red. How do I do this? Sincerely Henrik library(cluster) D <- matrix(nr=4,

Re: [R] hcluster with linkage median

2010-09-28 Thread Kennedy
Thank you Peter for your help. I had tried hclust before but I made the mistake of using the D matrix above instead of a dist object. Hence library(flashClust) d <- as.dist(D) # Clustering using hclust hc <- hclust(d, method = "median",members=NULL) # Clustering using flashClust fc

[R] hcluster with linkage median

2010-09-27 Thread Kennedy
Hi, I want to perform a hierarchical clustering using the median as linkage metric. As I understand it the function hcluster in package amap have this option but it does not produce the results that I expect. In the example below M is a matrix of similarities that is transformed into a matrix of

Re: [R] Aggregate certain rows in a matrix

2010-09-06 Thread Kennedy
Thank you very much for the help. I decided to go with the 'plyr' package but it is nice to have options. Have a lovely day. -- View this message in context: http://r.789695.n4.nabble.com/Aggregate-certain-rows-in-a-matrix-tp2528454p2529238.html Sent from the R help mailing list archive at Nabb

[R] Aggregate certain rows in a matrix

2010-09-06 Thread Kennedy
Hi, I have a matrix that looks like this a <- c(1,1,1,1,2,2,3,3,3,3) b <- c(2,2,2,3,4,4,4,5,5,6) c <- c(1,2,3,4,5,6,7,8,9,10) M <- matrix(nr=10,nc=3) M[,1] <- a M[,2] <- b M[,3] <- c > M [,1] [,2] [,3] [1,]121 [2,]122 [3,]123 [4,]

[R] Pseudo F statistics with index.G1

2010-07-06 Thread Kennedy
Hello, I have done some clustering with Agnes and want to calculate the pseudo F statistics using index.G1. It works for a low number of clusters but when i increase the number of clusters i eventually get the following message: Error in apply(x[cl == i, ], 2, mean) : dim(X) must have a posit

[R] (no subject)

2010-05-20 Thread ian kennedy
Here's another possibility: > x <- c("Apple12","HP42","Dell91") > strsplit(x,"(?<=\\D)(?=\\d)", perl=TRUE) [[1]] [1] "Apple" "12" [[2]] [1] "HP" "42" [[3]] [1] "Dell" "91" Krishna Tateneni writes: > Greetings, > > I have a vector of values that are a word followed by a number, e.g.,

[R] different plot symbols in key using xyplot

2009-10-25 Thread Stephen Kennedy
e key. xyplot(Force~Time, rawData, groups=Sample, pch=0:18, col="black", panel = panel.superpose, auto.key=list(space="right", pch=0:18)) Thanks, Steve Kennedy Stephen J. Kennedy, Ph.D. Consulting Contract Research & Development PLEASE NOTE: NEW EMAIL ADDRESS stephenjken

Re: [R] R 2.9 and XML

2009-05-05 Thread Ian Kennedy
ke to know if there's a better way. Ian Kennedy __ 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] for loop looking for file names

2008-12-02 Thread Steven Kennedy
ng. I was planning on using a for loop for the digits at the start of the file name, but I'm not sure how I can append the letter to the end of the number string. I'm also open to any ideas other than the for loop. Thanks, Steven Kennedy == "

[R] dataedit

2008-07-18 Thread Stephen Kennedy
To Whom It May Concern: Are there more examples / information regarding the use of 'dataedit'? If so, where might I find these? Regards, Steve Kennedy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help