axis label superscript

8 views
Skip to first unread message

coult...@gmail.com

unread,
Aug 12, 2019, 3:03:45 PM8/12/19
to Deducer
Is there way to add superscript text to an axis label (e.g., "km2" to "km2")? Thanks.

Bruce Miller

unread,
Aug 13, 2019, 8:39:26 AM8/13/19
to ded...@googlegroups.com
Hi all,

Seems there are not many are on this Deducer list any longer.

I am having an issue with trying to run iterations of the same analysis with a list of data sets.  I am assuming I am missing a basic step here.

Code I am trying is below.  Not certain if a NEXT call needs to be included somewhere or not.

# First step, was to create a folder with the data files for the analysis

# Set the WD for that directory

setwd("C://Embalonurids")

# Call all the names of the files in that folder

file.names <- dir(pattern = "*.txt") 

#Make a LOOP for the analysis

for(i in 1:length(file.names)){file <- read.table(file.names[i],header=TRUE) # read the text files one by one

  # Deducer code used

  file[c("TBC")] <- recode.variables(file[c("TBC")] , "0 -> NA;")

  # Create new BW variable and data set then change data file name for the analysis

  BW<-within(file,BW<-Fmax-Fmin)

  BW<-within(BW,FcH1<-Fc*.5)

  BW<-within(BW,FcH3<-FcH1*3)

  BatStats<-BW

BatStats<-Deducer::descriptive.table (vars = d (Dur,TBC,Fmin,Fmax,BW,Fmean,Fk,FcH1,Fc,FcH3,Sc,Pmc),data= BatStats,func.names =c("Valid N","Minimum","Maximum","Mean","St. Deviation"),func.additional= list(p75=function(x) quantile(x, c(0.75), na.rm=TRUE),p85=function(x) quantile(x, c(0.85), na.rm=TRUE),p90=function(x) quantile(x, c(0.90),na.rm=TRUE),p99=function(x) quantile(x, c(0.99),na.rm=TRUE)))

 ## Then the results need to be output

 name <- as.character(paste(file.names[i], ".csv", sep="")) # this creates an element that will have the name of the file that is used in each run

# I have tried both setting a new WD or simply defined where to writ the results

setwd("C://Embalonurids/Results")

write.csv(BatStats, name)    #this should assign the names of the files as it iterates one by one })

#also tried directing where to write the output

#write.csv(BatStats,name,file="C:\\Emballonurids\Results"))


If I manually load the data files in the data viewer window and run the steps one at a time it all works.

I would like to run this as an iteration as I have > 200 data files to process and would love to have it run in background while I am working on other things.

rudolf....@gmail.com

unread,
Aug 19, 2019, 2:45:09 AM8/19/19
to Deducer


On Tuesday, August 13, 2019 at 5:03:45 AM UTC+10, coult...@gmail.com wrote:
Is there way to add superscript text to an axis label (e.g., "km2" to "km2")? Thanks.

Yes, there is a simple way. It works with expression, see BMI example below.

ylab=expression("Body mass index" ~ (kg/m^{2}) 

rudolf....@gmail.com

unread,
Aug 19, 2019, 3:13:59 AM8/19/19
to Deducer
This is a good job for lapply, replacing a for loop and applying a function over multiple data frames.

 # put all the dataframes to a list

list1=list(name=dt1,name=dt2)

# define the function to be executed 

function1= function(x) 2*x

# then run by applying the function to the list

out1= lapply(list1, function1)



On Tuesday, August 13, 2019 at 5:03:45 AM UTC+10, coult...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages