[R] log transform a data frame

David Carlson dc@r|@on @end|ng |rom t@mu@edu
Wed Jun 14 00:14:25 CEST 2023


Your first data column appears to contain character data (e.g. SYCL) which
cannot be converted to numeric. You also appear to have 0's in the numeric
columns which will cause problems since log(0) is -Inf. Barplots are useful
for categorical data, but not continuous, numeric data which are better
handled with box plots or strip charts.

Do not use printouts of your data since it hides important information. Use
str(a11) and dput(a11) or dput(head(a11)) to provide useful information
about your data.

David L Carlson
Texas A&M University


On Tue, Jun 13, 2023 at 4:08 PM Ana Marija <sokovic.anamarija using gmail.com>
wrote:

> Hello, I have a data frame like this: d11=suppressWarnings(read.
> csv("/Users/anamaria/Downloads/B1. csv", stringsAsFactors=FALSE,
> header=TRUE)) > d11 X Domain. decomp. DD. com. . load Neighbor. search
> Launch. PP. GPU. ops. Comm. . coord. 1 SYCL 2. 1
> ZjQcmQRYFpfptBannerStart
> This Message Is From an External Sender
> This message came from outside your organization.
>
> ZjQcmQRYFpfptBannerEnd
>
> Hello,
>
> I have a data frame like this:
>
> d11=suppressWarnings(read.csv("/Users/anamaria/Downloads/B1.csv",
> stringsAsFactors=FALSE, header=TRUE))
>
> > d11
>      X Domain.decomp. DD.com..load Neighbor.search Launch.PP.GPU.ops.
> Comm..coord.
> 1 SYCL           2. 1            0             3.7               0. 1
>   1 .6
> 2 CUDA              2            0            3. 1                  0
>   1 .0
>   Force Wait...Comm..F PIE.mesh Wait.Bonded.GPU wait.GPU.NB.nonloc.
> 1 1 . 5           1 .3     65.6               0                   0
> 2  1 .2           1 .7     70.9               0                   0
>   Wait.GPU.NB.local NB.X.F.buffer.ops. Write.traje Update Constraints
> Comm..energies
> 1                 0                7.3         0.3    6.3         8.9
>      0.9
> 2                 0                4.4         0.3    4.3         9.7
>      0.9
>   PIE.redist..X.F PIE.spread PIE.gather PIE.3D.FFT PIE.3D.FFT.comm.
> PIE.solve.Elec
> 1            8. 1       29.7       19.9        6.0             1 .2
>    0.7
> 2             8.7       30.6      21 .3        8.6             1 .0
>    0.5
>
> I am trying to log transform the whole data frame, but I get this error:
>
> > d1=log(d11)
> Error in Math.data.frame(d11) :
>   non-numeric variable(s) in data frame: X, Domain.decomp.,
> Neighbor.search, Launch.PP.GPU.ops., Comm..coord., Force, Wait...Comm..F,
> PIE.redist..X.F, PIE.gather, PIE.3D.FFT.comm
>
>
> My goal is to make a stacked barplot like this:
> d2=as.matrix(sapply(d1, as.numeric))
> b<-barplot(d2, legend= rownames(data2), beside=
> TRUE,las=2,cex.axis=0.7,cex.names=0.7,ylim=c(0,80), col=c("#9e9ac8",
> "#6a51a3"))
>
> If I don't log transform  my code runs.
>
> Please advise,
> Ana
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, seehttps://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-help__;!!KwNVnqRv!GkOclaf0NPpoVxF8zs_a2pCGlBelsouhJKKR4wG4cG_gEycZ6t-N6nbPvxD1AxnYureFFthr_Nc-zXCU0czR4zGIstg$
> PLEASE do read the posting guide https://urldefense.com/v3/__http://www.R-project.org/posting-guide.html__;!!KwNVnqRv!GkOclaf0NPpoVxF8zs_a2pCGlBelsouhJKKR4wG4cG_gEycZ6t-N6nbPvxD1AxnYureFFthr_Nc-zXCU0czRLvLqcYM$
> and provide commented, minimal, self-contained, reproducible code.
>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list