Hello, i'm new using Rstudio, i'm trying to plot a data from a csv, i've got 65 columns and 57 rows just with data of abundance of organisms.
Before i do the plot i have to make an analysis with the data, but when i try to plot appears an error like this:
Error in plot.window(...) : you need finite values of 'ylim'
So i don't know what do i have to do, i remade the database and nothing, even i tried to reduce the data, just using like the half but nothing worked.
And i know that the script works because i used before with other data and worked.
Thank u for your help.
Hi, welcome!
We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.
If you've never heard of a reprex before, you might want to start by reading this FAQ:
Hello, thanks for the help, this is the part of the code that gives me the error , and this is an example of the database in csv format.
library(DescTools)
library(wavScalogram)
dt <- 4
tau <- 2
signals <- read.csv("Ind_activo.csv")
colores <- rainbow(65)
i = 1
n.time <- nrow(signals)
n.spp <- ncol(signals)
time <- 1:n.time
RelSpPhCumInt <- rep(NA, n.spp)
wSpPhInt <- SpPhInt <- matrix(NA, nrow = n.time, ncol = n.spp)
for (i in 1:n.spp) { #se hace un loop
SpPhPat <- signals[, i]
RelSpPhCumInt[i] <- sum(SpPhPat)
if (sd(SpPhPat) == 0)
SpPhInt[, i] <- SpPhPat/sum(SpPhPat)
if (sd(SpPhPat) > 0) {
wavelet <- cwt_wst(signal = SpPhPat, dt = dt, makefigure = FALSE)
z <- abs(wavelet$coefs)^tau # wavelet-transformed signal
SpPhInt[, i] <- rowSums(z)/sum(z)
}
}
wSpPhInt
RelSpPhCumInt <- RelSpPhCumInt/sum(RelSpPhCumInt)
for(i in 1:n.spp)
wSpPhInt[, i] <- RelSpPhCumInt[i]*SpPhInt[, i]
Plotting the community phenological patterns
windows(width = 4.5, height = 4)
opar <- par(no.readonly = T)
par(mar= c(5,5,4,6))
for(i in 1:ncol(signals)) {
if (i == 1)
plot (time, wSpPhInt[, i], type = "l", las = 1, bty = "l", xlab = "Time (day)", ylab = "Intensity", ylim = c(0, max(wSpPhInt)))
if (i != 1)
lines(time, wSpPhInt[,i], col=colores[i])
}
legend(x="topright",inset = c(-0.55,0),title = "Especies", legend = colnames(signals),lty = 1,
col = colores ,cex = 0.4, xpd = T)
The screenshot is not very useful since nobody can copy from it to test your code and figure out how to help, please read the guide in the link I gave you before and try to provide a proper reproducible example
Hello, sorry for that, here it is again.
even before the other error i mentioned i've got problems here
library(DescTools)
library(wavScalogram)
signals <- data.frame(
Accipiter_cooperii = c(0L,
0L,0L,0L,0L,0L),
Actitis_macularius = c(0L,
0L,0L,0L,0L,0L),
Amazilia_beryllina = c(0L,
0L,0L,0L,0L,0L),
Amazona_autumnalis = c(0L,
0L,0L,0L,0L,0L),
Amazona_oratrix = c(0L,
0L,0L,0L,0L,0L),
Amazona_viridigenalis = c(0L,
0L,0L,0L,0L,0L),
Anas_discors = c(0L,
0L,0L,1L,1L,0L),
Anas_diazi = c(12L,
10L,9L,10L,15L,12L),
Anas_platyrhynchos_domesticus = c(0L,
0L,3L,0L,0L,2L),
Ardea_alba = c(0L,
0L,0L,0L,0L,0L),
Aythya_collaris = c(0L,
2L,0L,0L,0L,0L),
Bombycilla_cedrorum = c(0L,
0L,0L,0L,1L,5L),
Butorides_virescens = c(0L,
0L,1L,0L,0L,0L),
Cardellina_pusilla = c(0L,
1L,0L,1L,0L,0L),
Columbina_inca = c(0L,
0L,0L,2L,2L,0L),
Contopus = c(0L,
0L,0L,0L,0L,0L),
Dryobates_scalaris = c(0L,
0L,0L,3L,0L,0L),
Empidonax = c(1L,
1L,3L,1L,0L,0L),
Fulica_americana = c(0L,
2L,1L,0L,1L,0L),
Geothlypis_trichas = c(0L,
0L,0L,0L,0L,0L),
Haemorhous_mexicanus = c(0L,
0L,2L,2L,4L,2L),
Hirundo_rustica = c(0L,
0L,0L,0L,0L,0L),
Icterus_bullockii = c(0L,
0L,0L,0L,0L,0L),
Icterus_spurius = c(0L,
0L,0L,0L,0L,0L),
Lampornis_clemenciae = c(0L,
0L,0L,0L,0L,0L),
Leiothlypis_celata = c(2L,
0L,2L,0L,1L,1L),
Leiothlypis_ruficapilla = c(0L,
0L,0L,0L,0L,0L),
Melanerpes_aurifrons = c(0L,
0L,0L,0L,0L,0L),
Melospiza_melodia = c(0L,
0L,0L,0L,0L,0L),
Melozone_fusca = c(0L,
0L,0L,0L,0L,0L),
Mimus_polyglottos = c(0L,
0L,0L,0L,0L,0L),
Mniotilta_varia = c(1L,
0L,0L,0L,1L,0L),
Molothrus_aeneus = c(0L,
0L,0L,0L,0L,0L),
Myiarchus_cinerascens = c(0L,
0L,0L,0L,0L,0L),
Myiopsitta_monachus = c(0L,
0L,0L,0L,0L,0L),
Parabuteo_unicinctus = c(0L,
0L,0L,0L,0L,0L),
Passer_domesticus = c(2L,
0L,0L,0L,0L,0L),
Passerina_cyanea = c(0L,
0L,0L,0L,0L,0L),
Pheucticus_melanocephalus = c(0L,
0L,0L,0L,0L,0L),
Piranga_flava = c(0L,
0L,0L,0L,0L,0L),
Piranga_ludoviciana = c(0L,
0L,0L,0L,0L,0L),
Podilymbus_podiceps = c(0L,
0L,0L,0L,1L,0L),
Polioptila_caerulea = c(1L,
3L,0L,0L,1L,1L),
Psaltriparus_minimus = c(0L,
0L,0L,0L,0L,0L),
Ptilogonis_cinereus = c(0L,
0L,0L,0L,0L,0L),
Pyrocephalus_rubinus = c(1L,
1L,3L,4L,6L,1L),
Quiscalus_mexicanus = c(5L,
1L,4L,4L,7L,1L),
Rhodothraupis_celaeno = c(0L,
0L,0L,0L,0L,0L),
Setophaga_coronata = c(8L,
5L,4L,2L,4L,4L),
Spatula_clypeata = c(2L,
8L,25L,15L,2L,0L),
Spinus_psaltria = c(0L,
0L,0L,0L,0L,0L),
Spizella_passerina = c(0L,
0L,0L,4L,2L,15L),
Streptopelia_decaocto = c(0L,
0L,0L,0L,0L,0L),
Sturnus_vulgaris = c(0L,
0L,0L,0L,0L,0L),
Thryomanes_bewickii = c(1L,
0L,1L,7L,0L,0L),
Toxostoma_curvirostre = c(0L,
0L,0L,0L,0L,0L),
Troglodytes_aedon = c(0L,
0L,0L,0L,0L,2L),
Turdus_migratorius = c(1L,
0L,2L,1L,0L,2L),
Turdus_rufopalliatus = c(0L,
0L,0L,0L,0L,0L),
Tyrannus_vociferans = c(0L,
0L,0L,0L,0L,0L),
Vireo = c(0L,
0L,0L,0L,0L,0L),
Vireo_flavifrons = c(0L,
0L,0L,0L,0L,0L),
Vireo_huttoni = c(0L,
0L,0L,0L,0L,0L),
Zenaida_macroura = c(0L,
0L,0L,0L,0L,0L),
Zenaida_asiatica = c(0L,
0L,0L,0L,0L,0L)
)
dt <- 4
tau <- 2
colores <- rainbow(65)
n.time <- nrow(signals)
n.spp <- ncol(signals)
time <- 1:n.time
RelSpPhCumInt <- rep(NA, n.spp)
wSpPhInt <- SpPhInt <- matrix(NA, nrow = n.time, ncol = n.spp)
for (i in 1:n.spp) {
SpPhPat <- signals[, i]
RelSpPhCumInt[i] <- sum(SpPhPat)
if (sd(SpPhPat) == 0)
SpPhInt[, i] <- SpPhPat/sum(SpPhPat)
if (sd(SpPhPat) > 0) {
wavelet <- cwt_wst(signal = SpPhPat, dt = dt, makefigure = FALSE)
z <- abs(wavelet$coefs)^tau
SpPhInt[, i] <- rowSums(z)/sum(z)
}
}
#Error in cwt_wst(signal = SpPhPat, dt = dt, makefigure = FALSE) :
#could not find function "cwt_wst"
Created on 2021-09-08 by the reprex package (v2.0.1)
This is weird, maybe you need to update the wavScalogram package
install.packages("wavScalogram")
Also, I would strongly recommend narrowing down your code to just the problematic part, a reprex should be minimal, too much code lowers your chances of getting help.
