RStudio Community
477 FOLLOWERS
RStudio provides open source and enterprise-ready professional software for data science teams using R and Python.
RStudio Community
8m ago
It is not at all clear to me what you want to plot from your data. Here is a density plot, with a log x scale, of all the values excluding the first row (the "headers") and the first column. That is about 2.8M values.
library(tidyverse)
#> Warning: package 'ggplot2' was built under R version 4.3.3
DF <- read.table("~/R/Play/DATA_SurArea_Dist.csv", sep = ",", header = FALSE, skip = 1)
AllVals <- unlist(DF[,2:107])
DF_all <- data.frame(Val = AllVals)
ggplot(DF_all, aes(Val)) + geom_density() +
scale_x_log10()
#> Warning in scale_x_log10(): log-10 transformation introduced infin ..read more
RStudio Community
8m ago
Hi, @FJCC! Thanks for pointing that out. I realized it was the wrong plot. However, I’m still interested in creating a similar plot, but including all the columns and fitting curves—perhaps using a log-normal distribution, as I mentioned in my previous comment. So, that i can get a smooth distribution curve.
Thanks for your time ..read more
RStudio Community
8m ago
I don't see any connection between the plot with the logarithmic x axis and the plot with the blue dots. To make the latter, it seems we need to plot the first row and the second row of the data you posted.
library(tidyverse)
#> Warning: package 'ggplot2' was built under R version 4.3.3
DF <- read.table("~/R/Play/DATA_SurArea_Dist.csv", sep = ",", header = FALSE, skip = 1)
DFx <- read.table("~/R/Play/DATA_SurArea_Dist.csv", sep = ",", header = FALSE, nrows = 1)
Xs <- unlist(DFx[1,2:107])
Ys <- unlist(DF[1,2:107])
DFplot <- data.frame(Xvals = Xs, Yvals = Ys)
ggplot(DFplot, ae ..read more
RStudio Community
8m ago
Thanks for your time.
But the x-axis values have now become the character format.
I mean 15.1 value now becomes x15_1, which I do not want to do that.
I am trying to fix my x-axis as 0 to 700 (these values are given as header)
I am trying to plot the figure just like the figure shared here.
A smooth fitting curve, not all the points ..read more
RStudio Community
1h ago
Plotted with
ggplot(DT_M, aes(x = variable, y = value)) + geom_point() # variable is a factor ..read more
RStudio Community
1h ago
I am not completely clear on what you want but try this:
suppressMessages(library(data.table))
suppressMessages(library(tidyverse))
suppressMessages(library(janitor))
DT <- fread("DATA_SurArea_Dist.csv", header = TRUE) %>% clean_names()
DT_M <- melt(DT, id.var = "the_time")
ggplot(DT_M, aes(x = variable, y = value)) + geom_point() # variable is a factor
## Or
DT_M[ , variable := as.character(variable)] # variable is character
ggplot(DT_M, aes(x = variable, y = value)) + geom_point()
Note that DT_M has 2,828,504 rows. On a lightweight laptop such as I am using, it is wor ..read more
RStudio Community
3h ago
Hi,
Thanks for your time
If the data were in 2 columns, it would be simple for me too. However, when you look at the dataset (Dropbox link), there are 106 columns, and all the headers serve as my x-axis values. Alternatively, I want to use the header value as the x-axis and the rest are y-axis values ..read more
RStudio Community
3h ago
Hi, I'm looking at this line:
Violet:
use_condaenv("keras-tf", required = T)
Do you have a python installation with conda environment named keras-tf on your computer? Do you use conda as your package manager for python?
If the answer is "yes" then you need to check python package installation named TensorFlow. This seems to be a python error ..read more
RStudio Community
3h ago
Hi,
The main package for plotting in R is ggplot2 which is much more intuitive than matplotlib.
Start by creating a dataframe with your columns and call it df.
library(ggplot2)
ggplot(data = df) +
geom_smooth(aes(x = col1, y = col2))
replace col1, col2 with your column names.
After you produce your basic plot, you can start tweak it with labs, xlabs, ylabs...
There are pretty good cheat sheets on Google for ggplot2, try using them ..read more