similar to: Trying to learn how to write an "advanced" function

Displaying 20 results from an estimated 10000 matches similar to: "Trying to learn how to write an "advanced" function"

2023 Mar 16
3
Trying to learn how to write an "advanced" function
Although I owe thanks to Ramus and Ivan, I still do not know how to write and "advanced" function. My most recent try (after looking at the material Ramus and Ivan set) still does not work. I am trying to run the lm function on two different formulae: 1) y~x, 2) y~x+z Any corrections would be appreciated! Thank you, John doit <- function(x){ ds <- deparse(substitute(x))
2017 Oct 23
2
Syntax for fit.contrast (from package gmodels)
David, Again you have my thanks!. You are correct. What I want is not technically a contrast. What I want is the estimate for "regional" and its SE. I don't mind if I get these on the log scale; I can get the anti-log. Can you suggest how I can get the point estimate and its SE for "regional"? The predict function will give the point estimate, but not (to my knowledge)
2018 Mar 21
3
Mean of a row of a data frame
I am trying to get the mean of a row of a data frame. My code follows: roop <- data.frame(x=c(1,2,3),y=c(4,5,2),z=c(0,9,4)) roop mean(roop[1,]) mean(roop[1,c("x","y","z")]) I get the following output: > roop x y z 1 1 4 0 2 2 5 9 3 3 2 4 > mean(roop[1,]) [1] NA Warning message: In mean.default(roop[1, ]) : argument is not numeric or logical:
2017 Oct 23
1
Syntax for fit.contrast (from package gmodels)
David, predict.glm and se.fit were exactly what I was looking for. Many thanks! John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax)
2017 Oct 22
3
Syntax for fit.contrast (from package gmodels)
David, Thank you for responding to my post. Please consider the following output (typeregional is a factor having two levels, "regional" vs. "general"): Call: glm(formula = events ~ type, family = poisson(link = log), data = data, offset = log(SS)) Deviance Residuals: Min 1Q Median 3Q Max -43.606 -17.295 -4.651 4.204 38.421 Coefficients:
2017 Oct 23
0
Syntax for fit.contrast (from package gmodels)
> On Oct 22, 2017, at 5:01 PM, Sorkin, John <jsorkin at som.umaryland.edu> wrote: > > David, > Again you have my thanks!. > You are correct. What I want is not technically a contrast. What I want is the estimate for "regional" and its SE. There needs to be a reference value for the contrast. Contrasts are differences. I gave you the choice of two references
2023 Apr 07
2
R does not run under latest RStudio
I have also had difficulty running R in RStudio. Has anyone else had problems? It will be a shame if we need to abandon R Studio. It is a very good IDE. John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene
2017 Oct 22
0
Syntax for fit.contrast (from package gmodels)
> On Oct 22, 2017, at 3:56 PM, Sorkin, John <jsorkin at som.umaryland.edu> wrote: > > David, > Thank you for responding to my post. > > Please consider the following output (typeregional is a factor having two levels, "regional" vs. "general"): > Call: > glm(formula = events ~ type, family = poisson(link = log), data = data, > offset =
2020 Oct 06
4
Solving a simple linear equation using uniroot give error object 'x' not found
Colleagues, I am trying to learn to use uniroot to solve a simple linear equation. I define the function, prove the function and a call to the function works. When I try to use uniroot to solve the equation I get an error message, Error in yfu n(x,10,20) : object 'x' not found. I hope someone can tell we how I can fix the problem
2006 May 12
4
Title of page with multiple plots
I want to place four plots on a page, and I would like to have all four plots share a common title. I have tried the following code, but the title is centered over the fourth graph and not centered across all four plots. Does anyone have any suggestions? R 2.1.1 windows xp oldpar<-par(mfcol =c(1,4),ask=TRUE) plot(p,varp) plot(p,SEp) plot(p,CVp) plot(p,ppval) title(paste("P and 95%CI
2017 Jun 20
2
by can not find transpose function
I am trying to transpose a dataframe by its first column using the by statement using the t function. When I use the by function, I get a message, Error in FUN(X[[i]], ...) : could not find function "FUN" I don't think I have a syntax error in my by statement because the by statment works using the print function. Data and an executable example follows: phonydata2 <-
2018 Mar 21
0
Mean of a row of a data frame
R > rowMeans(roop) [1] 1.666667 5.333333 3.000000 R > mean(as.numeric(roop[1,])) [1] 1.666667 :-) > On Mar 20, 2018, at 10:18 PM, Sorkin, John <jsorkin at som.umaryland.edu> wrote: > > I am trying to get the mean of a row of a data frame. My code follows: > > > roop <- data.frame(x=c(1,2,3),y=c(4,5,2),z=c(0,9,4)) > roop > mean(roop[1,]) >
2005 Jul 28
4
CSV file and date. Dates are read as factors!
I am using read.csv to read a CSV file (produced by saving an Excel file as a CSV file). The columns containing dates are being read as factors. Because of this, I can not compute follow-up time, i.e. Followup<-postDate-preDate. I would appreciate any suggestion that would help me read the dates as dates and thus allow me to calculate follow-up time. Thanks John John Sorkin M.D., Ph.D. Chief,
2005 Jul 29
6
Binary outcome with non-absorbing outcome state
I am trying to model data in which subjects are followed through time to determine if they fall, or do not fall. Some of the subjects fall once, some fall several times. Follow-up time varies from subject to subject. I know how to model time to the first fall (e.g. Cox Proportional Hazards, Kaplan-Meir analyses, etc.) but I am not sure how I can model the data if I include the data for those
2010 Dec 28
4
Reading sas7bdat files into R
Hi All, I am trying to import a .sas7bdat file into R. I tried using Hmisc package's sasxport.get() function. temp <- sasxport.get("path\abcd.sas7bdat") I get an error that says "Error in lookup.xport(file) : file not in SAS transfer format" I am not familiar with SAS transfer format. Could somebody please clarify what is it that I am missing, Thanks for your
2018 Mar 21
1
problem with rJAVA
I have installed rJava into my Windows 10 (64-bit) R instillation using the Tools > Install Packages command of my RStudion IDE. When I issued the R command in my R code library(rJava) I received the following error: library(rJava) Error: package or namespace load failed for ?rJava? in get(Info[i, 1], envir = env): lazy-load database 'C:/Users/John
2011 Mar 19
3
Generating repeated measures data
How would one generate data to be used in a simulation of a repeated measures ANOVA given a known (1) within-person correlation with known (2) mean and SD of data obtained at each of three times of observation? Thanks, John John Sorkin Chief Biostatistics and Informatics Univ. of Maryland School of Medicine Division of Gerontology and Geriatric Medicine JSorkin at grecc.umaryland.edu
2016 Apr 07
0
using apply to a data frame
??I would like to apply a function, fract, to the columns of a dataframe. I tried the following apply(data5NonEventEpochs,2,fract) but, no surprise it did not work as apply works on matrices not data frames. How can I apply a fuction to the columns of a data frame? (I can't covert data5NonEventsEpochs to a matrix as it contains character data). Thank you, John John David Sorkin M.D., Ph.D.
2005 Oct 11
2
Two factor (or more) non-parametric comparison of means
Can anyone suggest a good non-parametric test, and an R implementation of the test, that allows for two or more factors? Wilcoxon signed rank allows for only one. Thanks, John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics Baltimore VA Medical Center GRECC and University of Maryland School of Medicine Claude Pepper OAIC University of Maryland School of Medicine Division of
2007 Jan 18
3
selecting rows for inclusion in lm
I am having trouble selecting rows of a dataframe that will be included in a regression. I am trying to select those rows for which the variable Meno equals PRE. I have used the code below: difffitPre<-lm(data[,"diff"]~data[,"Age"]+data[,"Race"],data=data[data[,"Meno"]=="PRE",]) summary(difffitPre) The output from the summary indicates that