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

[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 == "