I'm very new to R and just finding my way, so be gentle! I've hit a swift halt doing some summary statistics on a simple continuous data field, divided into two categories. I'm getting the following error message. I am unclear why length(names(tth$Mins.to.hospital)) is zero and how to alter this. This is preventing me from carrying the summary data forward to any further analyses, which I need to create some new variables to account for the missing data points. I'm sure this is a very simple error, and I apologise for asking! Lynn The output is below - I have the epicalc program loaded.> aggregate(tth$Mins.to.hospital, by=list(DIRECT=tth$JR.1st.hospital))Note: Missing values removed. DIRECT count.. sum.. mean.. median.. sd.. min.. max.$ 1 No 76 202607 2665.8816 630 5297.410 217 26495 2 Yes 319 57859 181.3762 70 1314.982 0 23180 Warning messages: 1: In names(y)[length(names(y))] <- paste("count", as.character(substitute(x)), : number of items to replace is not a multiple of replacement length 2: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : number of items to replace is not a multiple of replacement length 3: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : number of items to replace is not a multiple of replacement length 4: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : number of items to replace is not a multiple of replacement length 5: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : number of items to replace is not a multiple of replacement length 6: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : number of items to replace is not a multiple of replacement length 7: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : number of items to replace is not a multiple of replacement length> colnames(tth)[1] "Time.to.hospital.arrival.present.only" "Mins.to.hospital" "JR.1st.hospital"> length(names(tth$Mins.to.hospital))[1] 0> length(paste("Count", as.character(substitute(tth$JR.1st.hospital))))[1] 3 [[alternative HTML version deleted]]
What are your expectations as to what "length(names(tth$Mins.to.hospital))" should be returning? You need to at least provide some data so we can reproduce the error, or 'str(tth)'. My guess is that tth$Mins.to.hospital does not have any 'names' attributes and therefore your error. So what is the problem you are trying to solve with the expression that is giving the error? On Fri, Aug 24, 2012 at 8:51 AM, Lynn Hutchings <lynn.hutchings at ndorms.ox.ac.uk> wrote:> I'm very new to R and just finding my way, so be gentle! > > > > I've hit a swift halt doing some summary statistics on a simple continuous data field, divided into two categories. I'm getting the following error message. I am unclear why length(names(tth$Mins.to.hospital)) is zero and how to alter this. This is preventing me from carrying the summary data forward to any further analyses, which I need to create some new variables to account for the missing data points. > > > > I'm sure this is a very simple error, and I apologise for asking! > > > > Lynn > > > > > > > > The output is below - I have the epicalc program loaded. > >> aggregate(tth$Mins.to.hospital, by=list(DIRECT=tth$JR.1st.hospital)) > > Note: > Missing values removed. > > DIRECT count.. sum.. mean.. median.. sd.. min.. max.$ > 1 No 76 202607 2665.8816 630 5297.410 217 26495 > 2 Yes 319 57859 181.3762 70 1314.982 0 23180 > Warning messages: > 1: In names(y)[length(names(y))] <- paste("count", as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length > 2: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length > 3: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length > 4: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length > 5: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length > 6: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length > 7: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length >> colnames(tth) > [1] "Time.to.hospital.arrival.present.only" "Mins.to.hospital" "JR.1st.hospital" >> length(names(tth$Mins.to.hospital)) > [1] 0 >> length(paste("Count", as.character(substitute(tth$JR.1st.hospital)))) > [1] 3 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.
Hello, You must post a data example to get some help. Use dput( head(tth, 50) ) # paste the output of this in a post As for the warnings, they are not errors. They are telling you that it can't make a replacement. substitute(x) is probably returning NULL and the aggregate return value's column names are ill formed, 'count..' where it should be 'count.Mins.to.hospital'. Anyway, post a data example. Hope this helps, Rui Barradas Em 24-08-2012 13:51, Lynn Hutchings escreveu:> I'm very new to R and just finding my way, so be gentle! > > > > I've hit a swift halt doing some summary statistics on a simple continuous data field, divided into two categories. I'm getting the following error message. I am unclear why length(names(tth$Mins.to.hospital)) is zero and how to alter this. This is preventing me from carrying the summary data forward to any further analyses, which I need to create some new variables to account for the missing data points. > > > > I'm sure this is a very simple error, and I apologise for asking! > > > > Lynn > > > > > > > > The output is below - I have the epicalc program loaded. > >> aggregate(tth$Mins.to.hospital, by=list(DIRECT=tth$JR.1st.hospital)) > Note: > Missing values removed. > > DIRECT count.. sum.. mean.. median.. sd.. min.. max.$ > 1 No 76 202607 2665.8816 630 5297.410 217 26495 > 2 Yes 319 57859 181.3762 70 1314.982 0 23180 > Warning messages: > 1: In names(y)[length(names(y))] <- paste("count", as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length > 2: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length > 3: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length > 4: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length > 5: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length > 6: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length > 7: In names(y)[length(names(y))] <- paste(FUN[i], as.character(substitute(x)), : > number of items to replace is not a multiple of replacement length >> colnames(tth) > [1] "Time.to.hospital.arrival.present.only" "Mins.to.hospital" "JR.1st.hospital" >> length(names(tth$Mins.to.hospital)) > [1] 0 >> length(paste("Count", as.character(substitute(tth$JR.1st.hospital)))) > [1] 3 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.