我一直试图查看我的数据分布以查看它是否正常并使用r中的hist()函数。它最初工作,我看到数据非常左倾,所以我尝试记录转换它,我收到错误消息"无效的休息次数"。我在Mac上使用r studio Version 1.0.136,这是我在Microsoft Excel中作为csv文件的数据集示例:
我的代码:
#Import my dataset
library(readr)
LeafWaterPotentials <- read_csv("~/Desktop/LeafWaterPotentials.csv", col_types = cols(Block = col_factor(levels = c("1", "2", "3")), Solute.Potential = col_number(), Treatment = col_factor(levels = c("nID", "ID", "nInD", "InD")), Vapro.Reading = col_number(), WP = col_number(), leaf.turgor.potential = col_number(), water.potential.Mpa = col_number()))
#check whether the data has normal distribution
hist(LeafWaterPotentials$Solute.Potential) #distribution is skewed
#try log-transforming data (also tried sqrt and get same error)
hist(log(LeafWaterPotentials$Solute.Potential))
输出:
hist.default中的错误(日志(LeafWaterPotentials $ Solute.Potential)):
无效的休息次数&#39;
#Check summary of dataset
summary(LeafWaterPotentials)
输出:
summary(LeafWaterPotentials)
Cage Plant Treatment Block WP water.potential.Mpa
Min. :1.0 Min. :1.00 Length:144 1:48 Min. : 4.61 Min. :-4.120
1st Qu.:2.0 1st Qu.:2.75 Class :character 2:48 1st Qu.: 8.43 1st Qu.:-1.115
Median :3.5 Median :4.50 Mode :character 3:48 Median : 9.83 Median :-0.983
Mean :3.5 Mean :4.50 Mean :11.22 Mean :-1.122
3rd Qu.:5.0 3rd Qu.:6.25 3rd Qu.:11.14 3rd Qu.:-0.843
Max. :6.0 Max. :8.00 Max. :41.20 Max. :-0.461
NA's :1 NA's :1
Vapro.Reading Solute.Potential leaf.turgor.potential
Min. : 243.0 Min. :-4.006 Min. :-1.72500
1st Qu.: 307.0 1st Qu.:-1.026 1st Qu.:-0.21300
Median : 348.0 Median :-0.877 Median :-0.08400
Mean : 398.4 Mean :-1.004 Mean :-0.05753
3rd Qu.: 407.0 3rd Qu.:-0.774 3rd Qu.: 0.06800
Max. :1589.0 Max. :-0.613 Max. : 2.43700
NA's :7 NA's :7 NA's :7
这是截图,因为编码输出看起来有点混乱:
我对r比较新,但我想知道这个错误是否与NA值有关,但之前我已经用NA创建了对数转换数据的直方图,并且没有问题。