3

While testing a function for package I got this .out

* installing *source* package 'trib' ...
** R
Error in parse(outFile) : 
C:R/trib.Rcheck/00_pkg_src/trib/R/tribF.R:48:27: unexpected input
47: 
48:     CF[i]<-mean(All[[i]]$μ
                          ^
ERROR: unable to collate and parse R files for package 'trib'

The problem is μ (mu) symbol. All my files have it and I can use those functions. I'd like to use that function in package also, so that my colleagues can use csv files.

Function is below

trib.CoF <- function(x) { #gets file name length input returns coeficient of friction in bar plot generates global var CF

namesAll<-trib.names(x)
CF <<- vector(mode = "numeric")     #generate vector for values
for (i in 1:l_All){

CF[i]<-mean(All[[i]]$μ)}             #get all coefficient of friction data into CF

names(CF)<-namesAll
barplot(CF,main="Average Friction Coefficient",
      xlab="Samples",ylab="μ",xlim=c(0,length(CF)*1.25+1), ylim = c(0,1.2*max(CF)),col=c(1:l_All))    #generate bar plot
legend("topright", legend=signif(CF,6),col=c(1:l_All),pch=16,cex=0.8)                                 #add legends

}

It looks like this question but I can't find a solution.

Community
  • 1
  • 1
  • 1
    I'd use `mu` instead of `μ`. Using characters like that are asking for trouble. Not to mention harder to type if you don't use them on a regular basis. – Josh Aug 04 '15 at 15:05
  • The tables (.csv) files use μ so I thought I have to. But I found a solution. I'll use CF[i]<-mean(All[[i]][[4]])} #get all coefficient of friction data into CF instead. I think this will give the same result, but will need table with defined shape, so the 4th column is μ. – Gokce Mehmet AY Aug 05 '15 at 08:33

1 Answers1

2

I found a solution to my own question. It's rather a workaround but depends on table structure. Consider my table is as such

Time    Distance     Laps      µ          FrictionForce
0,100   0           0,00000   0,18478       0,55435

µ is the 4th column. So instead of using it's name µ I'll just use its number. I'll change

CF[i]<-mean(All[[i]]$μ)}             #get all coefficient of friction data into CF

with

CF[i]<-mean(All[[i]][[4]])} #get all coefficient of friction data into CF

This will eliminate non ASCII character error so I can compile as a package. I might have to write a table check function for input structure but describing it in manual and giving a data set should be enough.