I have a data frame with 3 columns (percentage of life-satisafction, agegroup and year). I want to visualize my data in the following way: percenatge of life-satisfaction for each age group once for the year 2014 and for 2020. My data for the percentage of life-satisfaction consists already of percentage values for each group and year.
How do I visualize this?
Example in Screenshot
data example
I have five data frames among which I want to run regressions:
df1: stock returns
df2: housing returns
df3: actual inflation rate
df4: expected inflation rate
df5: unexpected inflation rate
Dataframe example
Each of the data frames has the same format as above, with only different data inside it.
I want to do separate regression of housing and stocks against expected and unexpected inflation as below:
df1[i] ~ df4[i] + df5[i]
df2[i] ~ df4[i] + df5[i]
I want to compare the results of regression for periods where actual inflation (included in df3) is higher than the median value with periods where actual inflation is lower than the median value. For doing that, I need to create two subsamples from each data frame based on the value that each column has in df3.
Since I don't have a deep knowledge of R, I don't know how to do it. Is it possible to do it? and how? Or is it better to create 13 different data frames for each country?
Thank you in advance!
I have a single column data frame of race times called RaceTimes, with the data frame called R5.
I don't know what ggplot to use and how to get the percentile on the x-axis.
I have a spreadsheet with 20 year time series data for 100 firms. The names of the 100 firms are in the first column, followed by each column containing values for a particular year (21 columns).
I would like to replace the values in each column with the assigned decile distribution for each firm in that particular year. How would I go about doing this in R?
This question already has answers here:
population pyramid density plot in r
(5 answers)
Closed 9 years ago.
I have 11 data columns in a single data.frame, 10 of the columns are depth categories and one column contains one of two values (Day or Night).
Each row of data is populated with numeric values representing the percent of time spent in each depth category over a 4-hour period and has either Day or Night assigned to it in the Day_Night column indicating whether that 4-hour period was during the day or the night.
I would like to plot this data in a back to back histogram where each depth bin is listed vertically along the plot and values for the day are plotted in one histogram facing one way, while the values for the night are plotted facing the other way. I can't post a picture since I am new but to see what I mean just look at Figure 5 on page 8 of this publication.
EDIT: Here's the picture:
Thanks for the help!
You can use plotrix for example:
set.seed (123)
mm <- matrix (sample(seq(0,330,10),2000,rep=TRUE),ncol=2 )
ll <- lapply(as.data.frame(mm),
function(x)as.data.frame(table(cut(x,seq(0,330,10)))))
library(plotrix)
par(mar=pyramid.plot(ll$V1$Freq,ll$V2$Freq,
labels =ll$V1$Var1,
top.labels=c("NIGHT","","DAY"),
xlim=c(100,100),
main="Swimming depth",
lxcol="black",rxcol= "white",
gap=0,
do.first="plot_bg('pink')"))