similar to: Writing R Library

Displaying 20 results from an estimated 20000 matches similar to: "Writing R Library"

2001 Aug 15
2
FORTRAN in R
Hi, Can anyone tell me what might cause this error message? Error in .Fortran("swallocate", as.double(mtx), as.double(wt), as.integer(n), : C/Fortran function name not in load table This occurs when I copied the Splus stepwise() function into R. I can source into R fine, but when I need to call that function on some dataset, I got the above error message. Platform
2001 Sep 19
2
Save/Display R Work
Hi, I was tutoring in the lab when a student asked me this question. Is it possible to save the work done in R, then source it back in AND display all the work within R later? I know that one can save the history (i.e. all the codes in a session) in *.R format, then source it back in at a later stage. However the historical codes will not be displayed within R, only the line source(...) is
2002 Apr 15
1
Re: Writting R Function
Hi, I think I found the problem. It lies in my Fortran program. Is there a way, after a DO loop, to make sure it does NOT return anything? Cheers, Kevin On Mon, 15 Apr 2002, Ko-Kang Kevin Wang wrote: > Date: Mon, 15 Apr 2002 17:27:20 +1200 (NZST) > From: Ko-Kang Kevin Wang <kwan022 at stat1.stat.auckland.ac.nz> > To: R Help <r-help at stat.math.ethz.ch> > Subject:
2002 Sep 18
2
More on list to data frame (was: Re: List to Data Frame
Hi, Now suppose I have just one list called FOO, which has 25 objects, e.g.: [[1]] 1 2 3 4 5 [[2]] 6 7 8 9 10 . . . And I want to do something like: FRED <- data.frame(cbind(unlist(FOO[[1]]), unlist(FOO[[2]]), # ... for all 25 subsets )) Is it possible to do this, without doing unlist(FOO[[i]]) 25
2002 May 18
5
Length of a string
Hi, Suppose I have created something like this in R: foo <- "myfoo" and I want to find out the number of character in foo (in other words, R should return 5 since "myfoo" has 5 charactors. How can I do it? I tried: length(foo) but it returned 1. Cheers, Kevin ------------------------------------------------------------------------------ Ko-Kang Kevin Wang
2002 May 06
4
Subtitle?
Hi, Is it possible to add a subtitle that appears directly below the main title? I tried the "sub" parameter, but it adds sub-title to the bottom of the plot. Cheers, Kevin ------------------------------------------------------------------------------ Ko-Kang Kevin Wang Postgraduate PGDipSci Student Department of Statistics University of Auckland New Zealand Homepage:
2003 Dec 15
3
Julian Dates
Hi, I'm a bit confused how julian() works. If I understand right, it returns the number of days since the origin. I have a vector: > SLDATX[1:10] [1] "1986-01-06" "1986-01-17" "1986-02-02" "1986-02-04" [5] "1986-02-04" "1986-02-21" "1986-03-06" "1986-03-25" [9] "1986-04-06"
2002 Sep 23
4
Overall Title in par(mfrow)
Hi, Say I did something like: par(mfrow = c(1, 2)) plot(1:10) plot(1:10) and I'd like to have an overall title, i.e. a title that would appear, centered, on the top of both plots, rather than the top of the last plot. I tried: title("FOO", outer = T) but it doesn't appear right. Half of the FOO is outside the figure region and can't be seen... Is there another
2003 Mar 26
2
ifelse()
Hi, I'm not sure if this can be done but.. I know that with ifelse() I can do something like: ifelse(x <= 3, 1, 2) to go through each element in my vector x, and if x_i <= 3 substitute the number with 1 else with 2. Essentially I'll get a vector with 2 levels. Can I tweak it so I can get 3-levels? For example: if(x <= 3) then 1 elseif(3 < x <= 4) then 2
2001 Mar 21
3
Output Files..
Hi, Somehow I forgot how to do this... Say I have a command that produced a 28 x 28 data matrix. How can I output the matrix into a txt file (rather than copy/paste the matrix)? Thanks... Kevin ------------------------------------------------- Ko-Kang Kevin Wang Statistical Analysis Division Leader Software Developers' Klub University of Auckland New Zealand
2003 Nov 26
4
strptime Usage
Hi, I have a column in a dataframe in the form of: > as.vector(SLDATX[1:20]) [1] "1/6/1986" "1/17/1986" "2/2/1986" "2/4/1986" "2/4/1986" [6] "2/21/1986" "3/6/1986" "3/25/1986" "4/6/1986" "4/10/1986" [11] "4/23/1986" "4/30/1986" "5/8/1986"
2001 Aug 12
3
gam() and library( modreg )
Hi, I'm just wonder if there is an R equivalent function of gam() - which exist in Splus. Also does anyone know if the library( modreg ), which comes with the installation file of R 1.3.0 (Windows version), exists in the previous versions of R (again, Windows version)? Or does one need to install the library into the previous versions of R explicitly? Thanks, Ko-Kang Wang
2001 May 23
4
Matrix manipulation
Hi, Suppose I have a matrix with, say 12 columns. I would like to extract out column 2 ~ 8 and 11 ~ 12 then combine them together. I tried with success to extract out the columns by doing: foo <- test[,2:8] goo <- test[,11:12] However then I am having trouble combining foo and goo. Helps are appreciated! Cheers, Kevin ----------------------------------- Ko-Kang Kevin Wang
2002 Feb 04
1
row.names in read.table()
Hi, I was trying to read in the following data set by using: gas <- read.table("gas.tab", header = T) when I got the error message: Error in "row.names<-.data.frame"(*tmp*, value = row.names) : duplicate row.names are not allowed Any help are appreciated. Thanks, Ko-Kang Wang
2003 Mar 26
2
Plotting K-M Curve when have several strata
Hi, If I have: foo <- survfit(y ~ x) where y is a survival object and x is a n-level factor. The documentation says when I plot(foo), the confidence intervals will not be plotted (which I guess is understandable as otherwise the plot will get really messy). I tried to plot with confidence intervals by using: plot(foo, conf.int = TRUE) and indeed the resulting plot is messy. However
2002 Sep 24
4
print(), paste()
Hi, Suppose I have the following lines at the end of a function: answer <- c(2, 1, 0, 4, 5) # In fact, answer will be generate in my # function print(answer) # Print the answer # Now, find the best fitted n degree polynomial print(paste("The best fit is with", which.min(answer) - 1, "-degree polynomial")) this will return:
2002 Jun 08
2
More on for() Loop...
Hi, Say I want to do something like fitting 10 different sized trees with rpart() function. The only modification I need to do is to set 10 different cp's, which I have in a vector called foo. Can I do something like: for(i in 1:10) { rpart(y ~ ., cp = foo[i], data = mydata) } My problem is, I wish to save the 10 rpart objects into 10 different names, my.rpart1 ~ my.rpart10, for
2002 Sep 27
3
xtable()
Hi, Does anyone know how to manually configure the number of digits printed out from xtable()? For example, I'm exporting a data frame through xtable() into a LaTeX table, I only have two columns in the data frame so by default I only get two decimal places. But I'd like at least 5 decimal places. I had a look at ?xtable() but can't seem to find an example. Cheers, Kevin
2002 Jan 09
3
Build R Packages (man)
Hi there, I'm trying to get the manual for an R package (that I'm creating) to work... Firstly, I created the *.Rd files (by following the instructions in "Writing R Extensions" and using prompt() in R, then edit the *.Rd files. I then copy them into the "pkg/man" directory as suggested by the manual. However when I load the library (successfully) in R, I cannot
2002 May 10
1
barplot()
Hi, Is it possible to draw barplot with x-axis being shown? I looked up the help file and I couldn't seem to find it. For example, I tried to do x <- 1:9 p <- log10(1 + 1/x) barplot(p, xlab = "Digit d", ylab = "Probability", ylim = c(0, 0.35), axes = F, main = "Benford's Law Probability") axis(1, 1:9) axis(2, seq(0, 0.35, by = 0.05),